Skip to content

Commit

Permalink
fix: Always Output Step Summary, Change Output Name, and Changed PR C…
Browse files Browse the repository at this point in the history
…ontext Detection
  • Loading branch information
Kludgy4 committed Jan 2, 2025
1 parent 506aec6 commit 3f2c189
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ inputs:
required: true
default: "false"
outputs:
plan-markdown:
markdown:
description: The raw markdown output of the terraform plan
runs:
using: node20
Expand Down
18 changes: 9 additions & 9 deletions dist/index.js

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

29 changes: 14 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,26 @@ async function run() {
})
)

if (!inputs.skipEmpty || !planIsEmpty(plan)) {
const prContext = 'pull_request' in github.context.payload

// 3) Render the plan diff markdown and set it as output
const planMarkdown = await core.group('Render plan diff markdown', () => {
const markdown = renderMarkdown({ plan, header: inputs.header })
core.setOutput('plan-markdown', markdown)
return Promise.resolve(markdown)
})
// 3) Render the plan diff markdown and set it as output
const planMarkdown = await core.group('Render plan diff markdown', () => {
const markdown = renderMarkdown({ plan, header: inputs.header })
core.setOutput('markdown', markdown)
return Promise.resolve(markdown)
})

// 4) Add plan to GitHub step summary
await core.group('Adding plan to step summary', async () => {
await core.summary.addRaw(planMarkdown).write()
})

// 4) Post comment with markdown (if applicable)
if (!inputs.skipEmpty || !planIsEmpty(plan)) {
// 5) Post comment with markdown (if applicable)
const prContext = github.context.eventName === 'pull_request'
if (prContext === true) {
await core.group('Render comment', () => {
return createOrUpdateComment({ octokit, content: planMarkdown })
})
}

// 5) Add plan to GitHub step summary
await core.group('Adding plan to step summary', async () => {
await core.summary.addRaw(planMarkdown).write()
})
}
}

Expand Down

0 comments on commit 3f2c189

Please sign in to comment.