From 9bf421a4f4c960899e5072c1340ee90e98a9c545 Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sat, 1 Apr 2023 12:13:46 -0400 Subject: [PATCH 1/2] add option to disable comments --- action.yml | 4 ++++ bin/action.min.js | 3 ++- package-lock.json | 8 ++++---- src/index.ts | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 6566c985..5c452566 100644 --- a/action.yml +++ b/action.yml @@ -32,6 +32,10 @@ inputs: description: "How long should a preview live? See the preview channels docs for options" default: "7d" required: false + addComment: + description: "Add comment on pull request with preview URL" + default: true + required: false projectId: description: "The project to deploy to. If you leave this blank, make sure you check in diff --git a/bin/action.min.js b/bin/action.min.js index 1be0a92e..d2edf5c3 100644 --- a/bin/action.min.js +++ b/bin/action.min.js @@ -11415,6 +11415,7 @@ async function postChannelSuccessComment(github, context, result, commit) { const expires = core.getInput("expires"); const projectId = core.getInput("projectId"); +const enableComment = core.getInput("addComment"); const googleApplicationCredentials = core.getInput("firebaseServiceAccount", { required: true }); @@ -11510,7 +11511,7 @@ async function run() { 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 (token && isPullRequest && !!octokit && enableComment) { 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); diff --git a/package-lock.json b/package-lock.json index 92cfabde..6e7e8a6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,12 @@ { "name": "firebase-hosting-preview-action", + "version": "0.7.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "firebase-hosting-preview-action", + "version": "0.7.0", "devDependencies": { "@actions/core": "^1.2.6", "@actions/exec": "^1.0.3", @@ -25,8 +27,7 @@ "ts-jest": "^26.4.1", "ts-node": "^9.0.0", "typescript": "^4.0.3" - }, - "version": "0.7.0" + } }, "node_modules/@actions/core": { "version": "1.2.6", @@ -24319,6 +24320,5 @@ "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true } - }, - "version": "0.7.0" + } } diff --git a/src/index.ts b/src/index.ts index ef90f2db..7476319c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,6 +40,7 @@ import { // Inputs defined in action.yml const expires = getInput("expires"); const projectId = getInput("projectId"); +const enableComment = getInput("addComment"); const googleApplicationCredentials = getInput("firebaseServiceAccount", { required: true, }); @@ -139,7 +140,7 @@ async function run() { ? `[${urls[0]}](${urls[0]})` : urls.map((url) => `- [${url}](${url})`).join("\n"); - if (token && isPullRequest && !!octokit) { + if (token && isPullRequest && !!octokit && enableComment) { const commitId = context.payload.pull_request?.head.sha.substring(0, 7); await postChannelSuccessComment(octokit, context, deployment, commitId); From 5421c91af9712481d5f6eb7b2020a527c846c14d Mon Sep 17 00:00:00 2001 From: Christopher Dignam Date: Sat, 1 Apr 2023 14:21:01 -0400 Subject: [PATCH 2/2] fix build --- action.yml | 2 +- bin/action.min.js | 4 ++-- src/index.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 5c452566..95823499 100644 --- a/action.yml +++ b/action.yml @@ -34,7 +34,7 @@ inputs: required: false addComment: description: "Add comment on pull request with preview URL" - default: true + default: "true" required: false projectId: description: diff --git a/bin/action.min.js b/bin/action.min.js index d2edf5c3..08802f13 100644 --- a/bin/action.min.js +++ b/bin/action.min.js @@ -11415,7 +11415,7 @@ async function postChannelSuccessComment(github, context, result, commit) { const expires = core.getInput("expires"); const projectId = core.getInput("projectId"); -const enableComment = core.getInput("addComment"); +const addComment = core.getInput("addComment") === "true"; const googleApplicationCredentials = core.getInput("firebaseServiceAccount", { required: true }); @@ -11511,7 +11511,7 @@ async function run() { 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 && enableComment) { + if (token && isPullRequest && !!octokit && addComment) { 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); diff --git a/src/index.ts b/src/index.ts index 7476319c..f26113d0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,7 +40,7 @@ import { // Inputs defined in action.yml const expires = getInput("expires"); const projectId = getInput("projectId"); -const enableComment = getInput("addComment"); +const addComment = getInput("addComment") === "true"; const googleApplicationCredentials = getInput("firebaseServiceAccount", { required: true, }); @@ -140,7 +140,7 @@ async function run() { ? `[${urls[0]}](${urls[0]})` : urls.map((url) => `- [${url}](${url})`).join("\n"); - if (token && isPullRequest && !!octokit && enableComment) { + if (token && isPullRequest && !!octokit && addComment) { const commitId = context.payload.pull_request?.head.sha.substring(0, 7); await postChannelSuccessComment(octokit, context, deployment, commitId);