Skip to content

Commit e5ca79f

Browse files
committed
add more metadata about the committer and if the commit is verified to the deployment confirmation message
1 parent a48c420 commit e5ca79f

File tree

6 files changed

+38
-7
lines changed

6 files changed

+38
-7
lines changed

__tests__/functions/deployment-confirmation.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ beforeEach(() => {
8080
log_url: 'https://github.com/corp/test/actions/runs/12345',
8181
ref: 'cool-branch',
8282
sha: 'abc123',
83+
committer: 'monalisa',
84+
commit_html_url: 'https://github.com/corp/test/commit/abc123',
8385
isVerified: true,
8486
noopMode: false,
8587
isFork: false,
@@ -143,6 +145,7 @@ test('successfully prompts for deployment confirmation and gets confirmed by the
143145
data.params = null
144146
data.parsed_params = null
145147
data.environmentUrl = null
148+
data.isVerified = false
146149

147150
// Mock that the user adds a +1 reaction
148151
octokit.rest.reactions.listForIssueComment.mockResolvedValueOnce({

__tests__/main.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ beforeEach(() => {
130130
return {
131131
data: {
132132
sha: mock_sha,
133+
html_url: `https://github.com/corp/test/commit/${mock_sha}`,
133134
commit: {
134135
author: {
135136
date: '2024-10-15T12:00:00Z'
136137
},
137138
verification: no_verification
139+
},
140+
committer: {
141+
login: 'monalisa'
138142
}
139143
}
140144
}
@@ -1083,11 +1087,15 @@ test('detects an out of date branch and exits', async () => {
10831087
return {
10841088
data: {
10851089
sha: mock_sha,
1090+
html_url: `https://github.com/corp/test/commit/${mock_sha}`,
10861091
commit: {
10871092
author: {
10881093
date: '2024-10-15T12:00:00Z'
10891094
},
10901095
verification: no_verification
1096+
},
1097+
committer: {
1098+
login: 'monalisa'
10911099
}
10921100
}
10931101
}

dist/index.js

Lines changed: 13 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/deployment-confirmation.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export async function deploymentConfirmation(context, octokit, data) {
1717
In order to proceed with this deployment, __${context.actor}__ must react to this comment with either a 👍 or a 👎.
1818
1919
- Commit: \`${data.sha}\`
20+
- Committer: \`${data.committer}\` - **${data.isVerified ? 'verified' : 'unverified'}**
2021
- Environment: \`${data.environment}\`
2122
- Branch: \`${data.ref}\`
2223
- Deployment Type: \`${data.deploymentType}\`
@@ -40,7 +41,9 @@ export async function deploymentConfirmation(context, octokit, data) {
4041
"git": {
4142
"branch": "${data.ref}",
4243
"commit": "${data.sha}",
43-
"verified": ${data.isVerified}
44+
"verified": ${data.isVerified},
45+
"committer": "${data.committer}",
46+
"html_url": "${data.commit_html_url}"
4447
},
4548
"context": {
4649
"actor": "${context.actor}",

src/main.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ export async function run() {
466466
headers: API_HEADERS
467467
})
468468

469+
const committer = commitData.data.committer.login
470+
const commit_html_url = commitData.data.html_url
471+
469472
// Run commit safety checks
470473
const commitSafetyCheckResults = await commitSafetyChecks(context, {
471474
commit: commitData.data.commit,
@@ -627,7 +630,9 @@ export async function run() {
627630
parsed_params: parsed_params,
628631
github_run_id: github_run_id,
629632
noopMode: precheckResults.noopMode,
630-
isFork: precheckResults.isFork
633+
isFork: precheckResults.isFork,
634+
committer: committer,
635+
commit_html_url: commit_html_url
631636
}
632637
)
633638
if (deploymentConfirmed === true) {
@@ -675,7 +680,9 @@ export async function run() {
675680
"git": {
676681
"branch": "${precheckResults.ref}",
677682
"commit": "${precheckResults.sha}",
678-
"verified": ${commitSafetyCheckResults.isVerified}
683+
"verified": ${commitSafetyCheckResults.isVerified},
684+
"committer": "${committer}",
685+
"html_url": "${commit_html_url}"
679686
},
680687
"context": {
681688
"actor": "${context.actor}",

0 commit comments

Comments
 (0)