Skip to content

Commit 493c807

Browse files
committed
clean up branches workflow
1 parent a897c36 commit 493c807

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Commit Review Cleanup
2+
3+
on:
4+
pull_request_review:
5+
branches: "commit-review-**"
6+
7+
jobs:
8+
cleanup:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- run: |
12+
PR_URL="/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}"
13+
REMAINING=$(gh api $PR_URL/requested_reviewers | jq 'length')
14+
15+
if $REMAINING -eq 0; then
16+
BRANCHES=$(gh api --method PATCH $PR_URL -f state='closed' | jq '.base.ref,.head.ref')
17+
18+
for BRANCH in ${BRANCHES[@]}; do
19+
git push origin --delete $BRANCH
20+
done
21+
fi

.github/workflows/commit-review.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- main
77

88
env:
9-
REMOTE: origin
109
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1110

1211
jobs:
@@ -93,6 +92,8 @@ jobs:
9392
pull_request:
9493
runs-on: ubuntu-latest
9594
needs: check
95+
env:
96+
REMOTE: origin
9697
steps:
9798
- uses: actions/checkout@v3
9899
with:

0 commit comments

Comments
 (0)