Skip to content

Commit 28586d5

Browse files
authored
[ci] Updated CI failure bot caller: permissions, PR author
1 parent fab8fc4 commit 28586d5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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

Lines changed: 8 additions & 4 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 }}
@@ -34,8 +34,8 @@ jobs:
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 "")
38-
if [ -z "$pr_author" ]; then
37+
pr_author=$(gh pr view "$pr_number" --repo "$REPO" --json author --jq '.author.login // empty' 2>/dev/null || echo "")
38+
if [ -z "$pr_author" ] || [ "$pr_author" = "null" ]; then
3939
echo "::warning::Could not fetch PR author for PR #$pr_number"
4040
fi
4141
echo "number=$pr_number" >> "$GITHUB_OUTPUT"
@@ -68,6 +68,10 @@ jobs:
6868
call-ci-failure-bot:
6969
needs: find-pr
7070
if: ${{ needs.find-pr.outputs.pr_number != '' }}
71+
permissions:
72+
pull-requests: write
73+
actions: write
74+
contents: read
7175
uses: openwisp/openwisp-utils/.github/workflows/reusable-bot-ci-failure.yml@master
7276
with:
7377
pr_number: ${{ needs.find-pr.outputs.pr_number }}

0 commit comments

Comments
 (0)