Skip to content

Commit

Permalink
Add disableComment variable (#371)
Browse files Browse the repository at this point in the history
Co-authored-by: Wei <weilinzung@gmail.com>
  • Loading branch information
jhuleatt and weilinzung authored May 24, 2024
1 parent 3fe0fd5 commit 0cbcac4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions bin/action.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0cbcac4

Please sign in to comment.