File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 77 - completed
88
99permissions :
10- pull-requests : write
10+ pull-requests : read
1111 actions : read
1212 contents : read
1313
@@ -18,7 +18,7 @@ concurrency:
1818jobs :
1919 find-pr :
2020 runs-on : ubuntu-latest
21- if : ${{ github.event.workflow_run.conclusion == 'failure' }}
21+ if : ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' }}
2222 outputs :
2323 pr_number : ${{ steps.pr.outputs.number }}
2424 pr_author : ${{ steps.pr.outputs.author }}
3434 emit_pr() {
3535 local pr_number="$1"
3636 local pr_author
37- pr_author=$(gh pr view "$pr_number" --repo "$REPO" --json author --jq '.author.login' 2>/dev/null || echo "")
37+ pr_author=$(gh pr view "$pr_number" --repo "$REPO" --json author --jq '.author.login // empty ' 2>/dev/null || echo "")
3838 if [ -z "$pr_author" ]; then
39- echo "::warning::Could not fetch PR author for PR #$pr_number"
39+ pr_author="${{ github.event.workflow_run.actor.login }}"
40+ echo "::warning::Could not fetch PR author for PR #$pr_number; falling back to @$pr_author"
4041 fi
4142 echo "number=$pr_number" >> "$GITHUB_OUTPUT"
4243 echo "author=$pr_author" >> "$GITHUB_OUTPUT"
4950 fi
5051 HEAD_SHA="$EVENT_HEAD_SHA"
5152 echo "Payload empty. Searching for PR via Commits API..."
52- PR_NUMBER=$(gh api repos/$REPO/commits/$HEAD_SHA/pulls -q '. [0].number' 2>/dev/null || true)
53+ PR_NUMBER=$(gh api repos/$REPO/commits/$HEAD_SHA/pulls -q '[.[] | select(.state == "open")] [0].number' 2>/dev/null || true)
5354 if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
5455 echo "Found PR #$PR_NUMBER using Commits API."
5556 emit_pr "$PR_NUMBER"
6869 call-ci-failure-bot :
6970 needs : find-pr
7071 if : ${{ needs.find-pr.outputs.pr_number != '' }}
72+ permissions :
73+ pull-requests : write
74+ actions : write
75+ contents : read
7176 uses : openwisp/openwisp-utils/.github/workflows/reusable-bot-ci-failure.yml@master
7277 with :
7378 pr_number : ${{ needs.find-pr.outputs.pr_number }}
You can’t perform that action at this time.
0 commit comments