Skip to content

Commit ed9665c

Browse files
committed
add more attributes to the deployment payload
1 parent c1ab44e commit ed9665c

File tree

5 files changed

+76
-14
lines changed

5 files changed

+76
-14
lines changed

__tests__/main.test.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as isDeprecated from '../src/functions/deprecated-checks'
1616
import * as nakedCommandCheck from '../src/functions/naked-command-check'
1717
import * as validDeploymentOrder from '../src/functions/valid-deployment-order'
1818
import * as commitSafetyChecks from '../src/functions/commit-safety-checks'
19+
import * as timestamp from '../src/functions/timestamp'
1920
import {COLORS} from '../src/functions/colors'
2021

2122
const setOutputMock = jest.spyOn(core, 'setOutput')
@@ -113,7 +114,7 @@ beforeEach(() => {
113114
rest: {
114115
issues: {
115116
createComment: jest.fn().mockReturnValueOnce({
116-
data: {}
117+
data: {id: 123456}
117118
})
118119
},
119120
repos: {
@@ -153,7 +154,10 @@ beforeEach(() => {
153154
return true
154155
})
155156
jest.spyOn(reactEmote, 'reactEmote').mockImplementation(() => {
156-
return {data: {id: '123'}}
157+
return {data: {id: 123}}
158+
})
159+
jest.spyOn(timestamp, 'timestamp').mockImplementation(() => {
160+
return '2025-01-01T00:00:00.000Z'
157161
})
158162
jest.spyOn(prechecks, 'prechecks').mockImplementation(() => {
159163
return {
@@ -175,7 +179,8 @@ beforeEach(() => {
175179
.mockImplementation(() => {
176180
return {
177181
status: true,
178-
message: 'success'
182+
message: 'success',
183+
isVerified: true
179184
}
180185
})
181186
jest
@@ -964,7 +969,7 @@ test('detects an out of date branch and exits', async () => {
964969
rest: {
965970
issues: {
966971
createComment: jest.fn().mockReturnValueOnce({
967-
data: {}
972+
data: {id: 123123}
968973
})
969974
},
970975
repos: {
@@ -1063,7 +1068,8 @@ test('fails commitSafetyChecks', async () => {
10631068
return {
10641069
status: false,
10651070
message:
1066-
'### ⚠️ Cannot proceed with deployment... a scary commit was found'
1071+
'### ⚠️ Cannot proceed with deployment... a scary commit was found',
1072+
isVerified: false
10671073
}
10681074
})
10691075
jest.spyOn(actionStatus, 'actionStatus').mockImplementation(() => {
@@ -1266,7 +1272,14 @@ test('stores params and parsed params into context with complex params', async (
12661272
parsed_params,
12671273
sha: 'deadbeef',
12681274
type: 'branch-deploy',
1269-
github_run_id: 12345
1275+
github_run_id: 12345,
1276+
initial_comment_id: 123,
1277+
initial_reaction_id: 123,
1278+
deployment_started_comment_id: 123456,
1279+
timestamp: '2025-01-01T00:00:00.000Z',
1280+
commit_verified: true,
1281+
actor: 'monalisa',
1282+
stable_branch_used: false
12701283
})
12711284
})
12721285
expect(await run()).toBe('success')

dist/index.js

Lines changed: 33 additions & 6 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.

docs/deployment-payload.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ Here is the data that the branch-deploy Action will add to the deployment payloa
1111
"params": "<string>",
1212
"parsed_params": {},
1313
"github_run_id": 123,
14+
"initial_comment_id": 123,
15+
"initial_reaction_id": 123,
16+
"deployment_started_comment_id": 123456,
17+
"deployment_started_comment_id": 123123,
18+
"timestamp": "2025-01-01T00:00:00.000Z",
19+
"commit_verified": true,
20+
"actor": "<string>",
21+
"stable_branch_used": false
1422
}
1523
```
1624

@@ -19,3 +27,10 @@ Here is the data that the branch-deploy Action will add to the deployment payloa
1927
- `params` - This is the raw string of parameters that were passed to the branch-deploy Action. You can read more about parameters [here](./parameters.md).
2028
- `parsed_params` - This is the parsed version of the `params` string. This is a JSON object that is created by parsing the `params` string. You can read more about parameters [here](./parameters.md).
2129
- `github_run_id` - This is the ID of the GitHub Action run that created the deployment. This can be useful if you need to access the logs of the deployment.
30+
- `initial_comment_id` - This is the ID of the initial (trigger) comment that kicked off the branch-deploy Action. Example: `.deploy` would be the comment that triggered the deployment and this would be the ID of that comment.
31+
- `initial_reaction_id` - This is the ID of the initial reaction that was left on the trigger comment by the branch-deploy Action. This is usually a pair of eyes (👀) to indicate that the branch-deploy Action has detected the trigger comment and it is running logic.
32+
- `deployment_started_comment_id` - This is the ID of the comment that the branch-deploy Action leaves below the trigger comment. It usually contains information about the deployment that is about to take place. Example: `Deployment Triggered 🚀... GrantBirki, started a branch deployment to production`
33+
- `timestamp` - This is the timestamp of when the deployment was created from the perspective of the branch-deploy Action.
34+
- `commit_verified` - This is a boolean that indicates whether the commit that is being deployed is verified.
35+
- `actor` - This is the username of the user that triggered the deployment.
36+
- `stable_branch_used` - This is a boolean that indicates whether the stable branch was used for the deployment. This will be `true` if the stable branch was used and `false` if the stable branch was not used.

src/main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,14 @@ export async function run() {
730730
sha: precheckResults.sha,
731731
params: params,
732732
parsed_params: parsed_params,
733-
github_run_id: github_run_id
733+
github_run_id: github_run_id,
734+
initial_comment_id: context.payload.comment.id,
735+
initial_reaction_id: reactRes.data.id,
736+
deployment_started_comment_id: deploymentStartedComment.data.id,
737+
timestamp: deployment_start_time,
738+
commit_verified: commitSafetyCheckResults.isVerified,
739+
actor: context.actor,
740+
stable_branch_used: stableBranchUsed
734741
}
735742

736743
// Create a new deployment

0 commit comments

Comments
 (0)