From 497928fa7ba5ec4b21b027a11168c91a977a0642 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 8 Aug 2023 10:22:33 -0700 Subject: [PATCH] fix: concat strings and include verification status (#304) --- dist/index.js | 15 ++++++++------- package-lock.json | 4 ++-- package.json | 2 +- src/push-alert.ts | 15 ++++++++------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/dist/index.js b/dist/index.js index 9072b88..bcad6c6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32850,21 +32850,22 @@ function runPushAlert(args) { const commit = process.env.GITHUB_SHA; const reviewed = yield verifyCommitReview(client, commit); if (reviewed === false) { - const commitDetails = yield client.git.getCommit({ + const commitDetails = yield client.repos.getCommit({ repo: github.context.repo.repo, owner: github.context.repo.owner, - commit_sha: commit, + ref: commit, }); //notify channel var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`; - const message = `:red-c: @channel Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` + + const message = `:red-c: Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` + '\n' + `*Commit:* <${github_commit_url}|${commit.slice(0, 6)}>\n` + - `*Author:* \n` + - `*Committer:* \n` + + `*Author:* \n` + + `*Committer:* \n` + + `*Verified Commit:* ${commitDetails.data.commit.verification.verified ? ':check:' : ':red-bang:'} _${safeSlackString(commitDetails.data.commit.verification.reason)}_\n` + '*Message:*\n' + - '```\n'; - safeSlackString(commitDetails.data.message) + + '```\n' + + safeSlackString(commitDetails.data.commit.message) + '\n```'; const req = request.post(args.slackEndpoint, { json: { diff --git a/package-lock.json b/package-lock.json index 466a7b4..11c50b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "push-alert", - "version": "1.1.2", + "version": "1.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "push-alert", - "version": "1.1.2", + "version": "1.1.3", "license": "MIT", "dependencies": { "@actions/core": "^1.6.0", diff --git a/package.json b/package.json index 6ec3279..052a9b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "push-alert", - "version": "1.1.2", + "version": "1.1.3", "private": true, "description": "Push alert for monitoring unreviewed commits", "main": "dist/index.js", diff --git a/src/push-alert.ts b/src/push-alert.ts index 635b0b1..5b540d4 100644 --- a/src/push-alert.ts +++ b/src/push-alert.ts @@ -15,22 +15,23 @@ export async function runPushAlert(args) { const commit = process.env.GITHUB_SHA; const reviewed = await verifyCommitReview(client, commit); if (reviewed === false){ - const commitDetails = await client.git.getCommit({ + const commitDetails = await client.repos.getCommit({ repo: github.context.repo.repo, owner: github.context.repo.owner, - commit_sha: commit, + ref: commit, }); //notify channel var github_commit_url = `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/commit/${commit}`; - const message = `:red-c: @channel Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` + + const message = `:red-c: Unreviewed Commit in \`${github.context.repo.owner}/${github.context.repo.repo}\`\n` + '\n' + `*Commit:* <${github_commit_url}|${commit.slice(0, 6)}>\n` + - `*Author:* \n` + - `*Committer:* \n` + + `*Author:* \n` + + `*Committer:* \n` + + `*Verified Commit:* ${commitDetails.data.commit.verification.verified ? ':check:' : ':red-bang:'} _${safeSlackString(commitDetails.data.commit.verification.reason)}_\n` + '*Message:*\n' + - '```\n' - safeSlackString(commitDetails.data.message) + + '```\n' + + safeSlackString(commitDetails.data.commit.message) + '\n```'; const req = request.post(args.slackEndpoint,{ json:{