Skip to content

Commit

Permalink
Merge pull request #106 from github/add-additional-outputs
Browse files Browse the repository at this point in the history
Add Additional Outputs
  • Loading branch information
GrantBirki authored Mar 2, 2023
2 parents d182017 + ba234b0 commit 0c7c257
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ As seen above, we have two steps. One for a noop deploy, and one for a regular d
| fork_label | The API label field returned for the fork |
| fork_checkout | The console command presented in the GitHub UI to checkout a given fork locally |
| fork_full_name | The full name of the fork in "org/repo" format |
| initial_reaction_id | The reaction id for the initial reaction on the trigger comment |
| actor_handle | The handle of the user who triggered the action |

## Custom Deployment Messages ✏️

Expand Down
75 changes: 60 additions & 15 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ beforeEach(() => {
},
comment: {
body: '.deploy',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}

Expand Down Expand Up @@ -121,7 +124,10 @@ test('successfully runs the action on a deployment to development', async () =>
},
comment: {
body: '.deploy to development',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}

Expand Down Expand Up @@ -154,7 +160,10 @@ test('fails due to multiple commands in one message', async () => {
number: 123
},
comment: {
body: '.deploy .lock'
body: '.deploy .lock',
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('failure')
Expand Down Expand Up @@ -183,7 +192,10 @@ test('successfully runs the action in noop mode', async () => {
},
comment: {
body: '.deploy noop',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('success - noop')
Expand Down Expand Up @@ -217,7 +229,10 @@ test('runs the action in lock mode and fails due to bad permissions', async () =
},
comment: {
body: '.lock',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('failure')
Expand All @@ -244,7 +259,10 @@ test('successfully runs the action in lock mode', async () => {
},
comment: {
body: '.lock --reason testing a new feature',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('safe-exit')
Expand Down Expand Up @@ -285,7 +303,10 @@ test('successfully runs the action in lock mode - details only', async () => {
},
comment: {
body: '.lock --details',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('safe-exit')
Expand Down Expand Up @@ -326,7 +347,10 @@ test('successfully runs the action in lock mode - details only - --info flag', a
},
comment: {
body: '.lock --info',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('safe-exit')
Expand Down Expand Up @@ -367,7 +391,10 @@ test('successfully runs the action in lock mode - details only - lock alias wcid
},
comment: {
body: '.wcid',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('safe-exit')
Expand Down Expand Up @@ -401,7 +428,10 @@ test('successfully runs the action in lock mode and finds no lock - details only
},
comment: {
body: '.lock --details',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('safe-exit')
Expand Down Expand Up @@ -437,7 +467,10 @@ test('runs with the unlock trigger', async () => {
},
comment: {
body: '.unlock',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
jest.spyOn(unlock, 'unlock').mockImplementation(() => {
Expand Down Expand Up @@ -468,7 +501,10 @@ test('successfully runs the action after trimming the body', async () => {
number: 123
},
comment: {
body: '.deploy noop \n\t\n '
body: '.deploy noop \n\t\n ',
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('success - noop')
Expand Down Expand Up @@ -547,7 +583,10 @@ test('fails due to no valid environment targets being found in the comment body'
},
comment: {
body: '.deploy to chaos',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}
expect(await run()).toBe('safe-exit')
Expand Down Expand Up @@ -586,7 +625,10 @@ test('runs the .help command successfully', async () => {
},
comment: {
body: '.help',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}

Expand All @@ -613,7 +655,10 @@ test('runs the .help command successfully', async () => {
},
comment: {
body: '.help',
id: 123
id: 123,
user: {
login: 'monalisa'
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ outputs:
description: 'The full name of the fork in "org/repo" format'
deployment_id:
description: The ID of the deployment created by running this action
initial_reaction_id:
description: The reaction id for the initial reaction on the trigger comment
actor_handle:
description: The handle of the user who triggered the action
runs:
using: "node16"
main: "dist/index.js"
Expand Down
2 changes: 2 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ export async function run() {
const reactRes = await reactEmote(reaction, context, octokit)
core.setOutput('comment_id', context.payload.comment.id)
core.saveState('comment_id', context.payload.comment.id)
core.setOutput('initial_reaction_id', reactRes.data.id)
core.saveState('reaction_id', reactRes.data.id)
core.setOutput('actor_handle', context.payload.comment.user.login)

// If the command is a help request
if (isHelp) {
Expand Down

0 comments on commit 0c7c257

Please sign in to comment.