Skip to content

Commit 8f40ce2

Browse files
committed
Try to fix extraction of PR number in quality monitor call
1 parent 17e5b56 commit 8f40ce2

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

.github/workflows/quality-monitor-comment-pr.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,27 @@ permissions:
1313

1414
jobs:
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

0 commit comments

Comments
 (0)