Skip to content

Commit 5330f74

Browse files
authored
Approving a bot pr will retrigger approval check (#7982)
I am trying to remove the need to explicitly retrigger check-approvals (pull_requeest) for bot authored prs when user approves the change Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent 7b47788 commit 5330f74

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

.github/workflows/approvals.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: PR Approval Check
22

33
on:
4-
pull_request_review:
5-
types: [submitted, dismissed]
64
pull_request:
75
branches:
86
- "develop"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Re-runs the PR Approval Check workflow when a review is submitted or dismissed.
2+
# Re-running creates a new attempt on the existing approvals.yml workflow run, which
3+
# updates the `check-approvals` check_run in place. This avoids the gate getting stuck
4+
# behind a stale failed check_run from the original `pull_request` event run.
5+
6+
name: Re-run PR Approval Check on Review
7+
8+
on:
9+
pull_request_review:
10+
types: [submitted, dismissed]
11+
12+
permissions:
13+
actions: write
14+
15+
concurrency:
16+
group: rerun-approvals-${{ github.event.pull_request.head.sha }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
rerun:
21+
if: github.event.pull_request.base.ref == 'develop'
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 5
24+
steps:
25+
- name: Re-run approvals workflow for this PR's head SHA
26+
env:
27+
GH_TOKEN: ${{ github.token }}
28+
REPO: ${{ github.repository }}
29+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
30+
run: |
31+
set -euo pipefail
32+
run_id=$(gh api \
33+
"repos/$REPO/actions/workflows/approvals.yml/runs?head_sha=$HEAD_SHA" \
34+
--jq '.workflow_runs[0].id // empty')
35+
if [ -z "$run_id" ]; then
36+
echo "No approvals.yml run for $HEAD_SHA — nothing to re-run."
37+
exit 0
38+
fi
39+
echo "Re-running approvals.yml run $run_id"
40+
gh api -X POST "repos/$REPO/actions/runs/$run_id/rerun"

0 commit comments

Comments
 (0)