From 0cbcac4740c2bfb00d632f0b863b57713124eb5a Mon Sep 17 00:00:00 2001 From: Jeff <3759507+jhuleatt@users.noreply.github.com> Date: Fri, 24 May 2024 12:13:02 -0400 Subject: [PATCH] Add `disableComment` variable (#371) Co-authored-by: Wei --- README.md | 4 ++++ action.yml | 5 +++++ bin/action.min.js | 6 ++++-- src/index.ts | 12 ++++++------ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 481f426d..c755c437 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,10 @@ file relative to the root of your repository. Defaults to `.` (the root of your The version of `firebase-tools` to use. If not specified, defaults to `latest`. +### `disableComment` _{boolean}_ + +Disable commenting in a PR with the preview URL. + ## Outputs Values emitted by this action that can be consumed by other actions later in your workflow diff --git a/action.yml b/action.yml index c0c83d40..52bff61b 100644 --- a/action.yml +++ b/action.yml @@ -59,6 +59,11 @@ inputs: The version of firebase-tools to use. Defaults to `latest`. default: latest required: false + disableComment: + description: >- + Disable auto-commenting with the preview channel URL to the pull request + default: "false" + required: false outputs: urls: description: The url(s) deployed to diff --git a/bin/action.min.js b/bin/action.min.js index 300cd763..8324beb8 100644 --- a/bin/action.min.js +++ b/bin/action.min.js @@ -93181,6 +93181,7 @@ const octokit = token ? github.getOctokit(token) : undefined; const entryPoint = core.getInput("entryPoint"); const target = core.getInput("target"); const firebaseToolsVersion = core.getInput("firebaseToolsVersion"); +const disableComment = core.getInput("disableComment"); async function run() { const isPullRequest = !!github.context.payload.pull_request; let finish = details => console.log(details); @@ -93252,8 +93253,9 @@ async function run() { core.setOutput("expire_time", expireTime); core.setOutput("expire_time_formatted", expire_time_formatted); core.setOutput("details_url", urls[0]); - const urlsListMarkdown = urls.length === 1 ? `[${urls[0]}](${urls[0]})` : urls.map(url => `- [${url}](${url})`).join("\n"); - if (token && isPullRequest && !!octokit) { + if (disableComment === "true") { + console.log(`Commenting on PR is disabled with "disableComment: ${disableComment}"`); + } else if (token && isPullRequest && !!octokit) { var _context$payload$pull; const commitId = (_context$payload$pull = github.context.payload.pull_request) == null ? void 0 : _context$payload$pull.head.sha.substring(0, 7); await postChannelSuccessComment(octokit, github.context, deployment, commitId); diff --git a/src/index.ts b/src/index.ts index 03c9a949..fe34502b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,6 +50,7 @@ const octokit = token ? getOctokit(token) : undefined; const entryPoint = getInput("entryPoint"); const target = getInput("target"); const firebaseToolsVersion = getInput("firebaseToolsVersion"); +const disableComment = getInput("disableComment"); async function run() { const isPullRequest = !!context.payload.pull_request; @@ -136,12 +137,11 @@ async function run() { setOutput("expire_time_formatted", expire_time_formatted); setOutput("details_url", urls[0]); - const urlsListMarkdown = - urls.length === 1 - ? `[${urls[0]}](${urls[0]})` - : urls.map((url) => `- [${url}](${url})`).join("\n"); - - if (token && isPullRequest && !!octokit) { + if (disableComment === "true") { + console.log( + `Commenting on PR is disabled with "disableComment: ${disableComment}"` + ); + } else if (token && isPullRequest && !!octokit) { const commitId = context.payload.pull_request?.head.sha.substring(0, 7); await postChannelSuccessComment(octokit, context, deployment, commitId);