diff --git a/CHANGELOG.md b/CHANGELOG.md index a0e0ec79..58c4c7f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/README.md b/README.md index 3e9917d3..01889a58 100644 --- a/README.md +++ b/README.md @@ -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 }}` diff --git a/action.yml b/action.yml index 0f5b995e..b4c7b5e7 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/src/__tests__/config.test.ts b/src/__tests__/config.test.ts index c6b1344d..8e821edd 100644 --- a/src/__tests__/config.test.ts +++ b/src/__tests__/config.test.ts @@ -8,6 +8,7 @@ const defaultConfig: Record = { 'github-token': 'n/a', 'pulumi-version': '^3', 'comment-on-pr': 'false', + 'comment-on-summary': 'false', upsert: 'false', remove: 'false', refresh: 'false', @@ -40,6 +41,7 @@ describe('config.ts', () => { "command": "up", "commentOnPr": false, "commentOnPrNumber": undefined, + "commentOnSummary": false, "configMap": undefined, "editCommentOnPr": false, "githubToken": "n/a", diff --git a/src/config.ts b/src/config.ts index f84e0270..52ca7880 100644 --- a/src/config.ts +++ b/src/config.ts @@ -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'), diff --git a/src/main.ts b/src/main.ts index 24f48e59..c3b7031c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -124,6 +124,13 @@ const runAction = async (config: Config): Promise => { } } + 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); }