Skip to content

Commit 0cbcac4

Browse files
jhuleattweilinzung
andauthored
Add disableComment variable (#371)
Co-authored-by: Wei <weilinzung@gmail.com>
1 parent 3fe0fd5 commit 0cbcac4

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ file relative to the root of your repository. Defaults to `.` (the root of your
147147

148148
The version of `firebase-tools` to use. If not specified, defaults to `latest`.
149149

150+
### `disableComment` _{boolean}_
151+
152+
Disable commenting in a PR with the preview URL.
153+
150154
## Outputs
151155

152156
Values emitted by this action that can be consumed by other actions later in your workflow

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ inputs:
5959
The version of firebase-tools to use. Defaults to `latest`.
6060
default: latest
6161
required: false
62+
disableComment:
63+
description: >-
64+
Disable auto-commenting with the preview channel URL to the pull request
65+
default: "false"
66+
required: false
6267
outputs:
6368
urls:
6469
description: The url(s) deployed to

bin/action.min.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93181,6 +93181,7 @@ const octokit = token ? github.getOctokit(token) : undefined;
9318193181
const entryPoint = core.getInput("entryPoint");
9318293182
const target = core.getInput("target");
9318393183
const firebaseToolsVersion = core.getInput("firebaseToolsVersion");
93184+
const disableComment = core.getInput("disableComment");
9318493185
async function run() {
9318593186
const isPullRequest = !!github.context.payload.pull_request;
9318693187
let finish = details => console.log(details);
@@ -93252,8 +93253,9 @@ async function run() {
9325293253
core.setOutput("expire_time", expireTime);
9325393254
core.setOutput("expire_time_formatted", expire_time_formatted);
9325493255
core.setOutput("details_url", urls[0]);
93255-
const urlsListMarkdown = urls.length === 1 ? `[${urls[0]}](${urls[0]})` : urls.map(url => `- [${url}](${url})`).join("\n");
93256-
if (token && isPullRequest && !!octokit) {
93256+
if (disableComment === "true") {
93257+
console.log(`Commenting on PR is disabled with "disableComment: ${disableComment}"`);
93258+
} else if (token && isPullRequest && !!octokit) {
9325793259
var _context$payload$pull;
9325893260
const commitId = (_context$payload$pull = github.context.payload.pull_request) == null ? void 0 : _context$payload$pull.head.sha.substring(0, 7);
9325993261
await postChannelSuccessComment(octokit, github.context, deployment, commitId);

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const octokit = token ? getOctokit(token) : undefined;
5050
const entryPoint = getInput("entryPoint");
5151
const target = getInput("target");
5252
const firebaseToolsVersion = getInput("firebaseToolsVersion");
53+
const disableComment = getInput("disableComment");
5354

5455
async function run() {
5556
const isPullRequest = !!context.payload.pull_request;
@@ -136,12 +137,11 @@ async function run() {
136137
setOutput("expire_time_formatted", expire_time_formatted);
137138
setOutput("details_url", urls[0]);
138139

139-
const urlsListMarkdown =
140-
urls.length === 1
141-
? `[${urls[0]}](${urls[0]})`
142-
: urls.map((url) => `- [${url}](${url})`).join("\n");
143-
144-
if (token && isPullRequest && !!octokit) {
140+
if (disableComment === "true") {
141+
console.log(
142+
`Commenting on PR is disabled with "disableComment: ${disableComment}"`
143+
);
144+
} else if (token && isPullRequest && !!octokit) {
145145
const commitId = context.payload.pull_request?.head.sha.substring(0, 7);
146146

147147
await postChannelSuccessComment(octokit, context, deployment, commitId);

0 commit comments

Comments
 (0)