Skip to content

Commit

Permalink
retry with check_id instead of run_id
Browse files Browse the repository at this point in the history
Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com>
  • Loading branch information
rdhar committed May 15, 2024
1 parent a84f478 commit 33a2a28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,10 @@ runs:

# On pull_request, update check status with the job summary before exiting.
- name: Update check status
if: ${{ (success() || failure()) && github.event_name == 'pull_request' }}
if: ${{ (success() || failure()) && steps.pr_comment.outcome == 'success' }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
check_id: ${{ steps.pr_comment.outputs.check_id }}
tf_summary: ${{ steps.pr_comment.outputs.summary }}
with:
retries: 3
Expand Down
5 changes: 3 additions & 2 deletions scripts/comment_tf_output.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ ${process.env.tf_fmt}
});
const matrix = JSON.parse(process.env.matrix);
const job_name = `${context.job}${matrix ? ` (${Object.values(matrix).join(", ")})` : ""}`;
const job_url = workflow_run.jobs.find((job) => job.name === job_name).html_url;
const check_url = workflow_run.jobs.find((job) => job.name === job_name).html_url;
core.setOutput("check_id", workflow_run.jobs.find((job) => job.name === job_name).id);

// Display the: TF command, TF output, and workflow authorip.
const comment_output = `
<details><summary>${comment_summary}</br>
###### ${context.workflow} by @${context.actor} via [${context.eventName}](${job_url}) at ${context.payload.pull_request?.updated_at || context.payload.comment?.updated_at}.</summary>
###### ${context.workflow} by @${context.actor} via [${context.eventName}](${check_url}) at ${context.payload.pull_request?.updated_at || context.payload.comment?.updated_at}.</summary>
\`\`\`hcl
${process.env.tf_output}
Expand Down
2 changes: 1 addition & 1 deletion scripts/update_check_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = async ({ github, context }) => {
const update_check_status = await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: context.runId,
check_run_id: process.env.check_id,
output: {
summary: "OUTPUT SUMMARY",
text: process.env.tf_summary,
Expand Down

0 comments on commit 33a2a28

Please sign in to comment.