File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,17 +13,27 @@ permissions:
1313
1414jobs :
1515 comment :
16- if : ${{ github.event.workflow_run.event == 'pull_request' }}
16+ if : ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
1717 runs-on : ubuntu-latest
1818 name : Comment on PR
1919
2020 steps :
2121 - name : Extract PR number and SHA
2222 id : pr
2323 run : |
24- pr_number='${{ github.event.workflow_run.pull_requests[0].number }}'
24+ pr_number=$(jq -r '(.pull_requests[0].number // empty)' <<<'${{ toJson(github.event.workflow_run) }}')
25+ if [ -z "$pr_number" ] || [ "$pr_number" = "null" ]; then
26+ echo "No PR associated with this workflow_run (pull_requests array empty)." >&2
27+ echo "Workflow run event: ${{ github.event.workflow_run.event }}" >&2
28+ exit 1
29+ fi
2530 echo "number=$pr_number" >> "$GITHUB_OUTPUT"
31+
2632 sha='${{ github.event.workflow_run.head_sha }}'
33+ if [ -z "$sha" ]; then
34+ echo "Missing head_sha in workflow_run payload." >&2
35+ exit 1
36+ fi
2737 echo "sha=$sha" >> "$GITHUB_OUTPUT"
2838 - name : Checkout PR
2939 uses : actions/checkout@v6
You can’t perform that action at this time.
0 commit comments