Skip to content

Commit

Permalink
refactor: Combined PR Comment Post Conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
Kludgy4 committed Jan 16, 2025
1 parent 44104cc commit 562a13f
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,22 @@ async function run() {
)

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

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

if (!inputs.skipEmpty || !planIsEmpty(plan)) {
if ((!inputs.skipEmpty || !planIsEmpty(plan)) && github.context.eventName === 'pull_request') {
// 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 })
})
}
await core.group('Render comment', () => {
return createOrUpdateComment({ octokit, content: planMarkdown })
})
}
}

Expand Down

0 comments on commit 562a13f

Please sign in to comment.