Skip to content

Commit

Permalink
Include workflow and job in PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
bigdaz committed Jan 1, 2024
1 parent 9682002 commit 0ad47f0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/job-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,20 @@ async function addPRComment(content: string): Promise<void> {

const context = github.context
if (context.payload.pull_request == null) {
core.info('Not a PR')
core.info(`Issue number: ${context.issue.number}`)
core.info(`Context payload: ${JSON.stringify(context.payload)}`)
core.info(`Context: ${JSON.stringify(context)}`)
core.info('No pull_request trigger: not adding PR comment')
return
}

const pull_request_number = context.payload.pull_request.number
core.info(`Adding Job Summary as comment to PR #${pull_request_number}.`)

const prComment = `<h3>Summary for gradle-build-action: ${github.context.workflow} - ${github.context.job}</h3>\n${content}`

const octokit = github.getOctokit(github_token)
await octokit.rest.issues.createComment({
...context.repo,
issue_number: pull_request_number,
body: content
body: prComment
})
} catch (error) {
core.warning(`Failed to generate PR comment: ${String(error)}`)
Expand All @@ -62,10 +61,9 @@ function renderSummaryTable(results: BuildResult[]): string {
}

return `
<h3>Gradle Builds</h3>
<table>
<tr>
<th>Root Project</th>
<th>Gradle Root Project</th>
<th>Requested Tasks</th>
<th>Gradle Version</th>
<th>Build Outcome</th>
Expand Down

0 comments on commit 0ad47f0

Please sign in to comment.