Skip to content

Commit 883f27d

Browse files
committed
ci: improve release gate approval counting and remove paths filter
1 parent c178bb3 commit 883f27d

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

.github/workflows/release-gate.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Release gate
33
on:
44
pull_request:
55
types: [opened, synchronize, reopened]
6-
paths:
7-
- "**/version.py"
86
pull_request_review:
97
types: [submitted, dismissed]
108

@@ -14,24 +12,28 @@ permissions:
1412
jobs:
1513
release-gate:
1614
name: Release gate
17-
if: startsWith(github.event.pull_request.head.ref, 'release/')
1815
runs-on: ubuntu-latest
1916
steps:
20-
- name: Verify PR was created by GitHub Actions
17+
- name: Check release PR requirements
2118
env:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
2221
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
22+
PR_NUMBER: ${{ github.event.pull_request.number }}
23+
REPO: ${{ github.repository }}
2324
run: |
25+
if [[ "$HEAD_REF" != release/* ]]; then
26+
echo "Not a release PR, skipping"
27+
exit 0
28+
fi
29+
2430
if [ "$PR_AUTHOR" != "github-actions[bot]" ]; then
2531
echo "::error::Release PRs must be created by the publish workflow, not by '$PR_AUTHOR'"
2632
exit 1
2733
fi
2834
29-
- name: Require at least 2 approvals
30-
env:
31-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
run: |
33-
approvals=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
34-
--jq '[.[] | select(.state == "APPROVED") | .user.login] | unique | length')
35+
approvals=$(gh api "repos/$REPO/pulls/$PR_NUMBER/reviews" \
36+
--jq '[group_by(.user.login)[] | sort_by(.submitted_at) | last | select(.state == "APPROVED") | .user.login] | length')
3537
echo "Approvals: $approvals"
3638
if [ "$approvals" -lt 2 ]; then
3739
echo "::error::Release PRs require at least 2 approvals (got $approvals)"

0 commit comments

Comments
 (0)