Skip to content

Commit d4d013f

Browse files
authored
[ci] Updated CI failure bot caller
- Fixed PR author info - Scoped write permissions to the retry job, not the whole workflow.
1 parent 45b24b6 commit d4d013f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

.github/workflows/bot-ci-failure.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- completed
88

99
permissions:
10-
pull-requests: write
10+
pull-requests: read
1111
actions: read
1212
contents: read
1313

@@ -18,7 +18,7 @@ concurrency:
1818
jobs:
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 }}
@@ -35,9 +35,8 @@ jobs:
3535
local pr_number="$1"
3636
local pr_author
3737
pr_author=$(gh pr view "$pr_number" --repo "$REPO" --json author --jq '.author.login // empty' 2>/dev/null || echo "")
38-
if [ -z "$pr_author" ]; then
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"
38+
if [ -z "$pr_author" ] || [ "$pr_author" = "null" ]; then
39+
echo "::warning::Could not fetch PR author for PR #$pr_number"
4140
fi
4241
echo "number=$pr_number" >> "$GITHUB_OUTPUT"
4342
echo "author=$pr_author" >> "$GITHUB_OUTPUT"
@@ -69,6 +68,10 @@ jobs:
6968
call-ci-failure-bot:
7069
needs: find-pr
7170
if: ${{ needs.find-pr.outputs.pr_number != '' }}
71+
permissions:
72+
pull-requests: write
73+
actions: write
74+
contents: read
7275
uses: openwisp/openwisp-utils/.github/workflows/reusable-bot-ci-failure.yml@master
7376
with:
7477
pr_number: ${{ needs.find-pr.outputs.pr_number }}

0 commit comments

Comments
 (0)