Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: comment on GitHub step summary #986

Merged
merged 2 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## HEAD (Unreleased)

- feat: comment on GitHub step summary.
([#986](https://github.com/pulumi/actions/pull/986))
- feat: Add Update Plan Functionality
([#994](https://github.com/pulumi/actions/pull/994))

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ The action can be configured with the following arguments:
of the Pulumi action to the PR. Ignored unless `${{ github.event }}` type is
`pull_request`.

- `comment-on-summary` - (optional) If `true`, then the action will add the
results of the Pulumi action to the GitHub step summary.

- `github-token` - (optional) A GitHub token that has access levels to allow the
Action to comment on a PR. Defaults to `${{ github.token }}`

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
comment-on-pr-number:
description: 'Overrides the PR used to comment on'
required: false
comment-on-summary:
description: 'If true, a comment on the GitHub step summary will be created'
required: false
default: 'false'
github-token:
description: 'Github Token'
required: false
Expand Down
2 changes: 2 additions & 0 deletions src/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const defaultConfig: Record<string, string> = {
'github-token': 'n/a',
'pulumi-version': '^3',
'comment-on-pr': 'false',
'comment-on-summary': 'false',
upsert: 'false',
remove: 'false',
refresh: 'false',
Expand Down Expand Up @@ -40,6 +41,7 @@ describe('config.ts', () => {
"command": "up",
"commentOnPr": false,
"commentOnPrNumber": undefined,
"commentOnSummary": false,
"configMap": undefined,
"editCommentOnPr": false,
"githubToken": "n/a",
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function makeConfig() {
githubToken: getInput('github-token'),
commentOnPr: getBooleanInput('comment-on-pr'),
commentOnPrNumber: getNumberInput('comment-on-pr-number', {}),
commentOnSummary: getBooleanInput('comment-on-summary'),
upsert: getBooleanInput('upsert'),
remove: getBooleanInput('remove'),
refresh: getBooleanInput('refresh'),
Expand Down
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ const runAction = async (config: Config): Promise<void> => {
}
}

if (config.commentOnSummary) {
await core.summary
.addHeading(`Pulumi ${config.stackName} results`)
.addCodeBlock(output, "diff")
.write();
}

if (config.remove && config.command === 'destroy') {
stack.workspace.removeStack(stack.name);
}
Expand Down