Skip to content

Commit 3f62e4d

Browse files
authored
Merge pull request #198 from redhat-appstudio/cleanup-prs
feat(workflow): Create workflow that cleans up and closes PRS
2 parents 6c0e691 + 93eb1ed commit 3f62e4d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/cleanup-prs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Close release-* PRs
2+
3+
on:
4+
# Manual
5+
workflow_dispatch:
6+
schedule:
7+
# Run daily at 2am UTC
8+
- cron: "0 2 * * *"
9+
10+
permissions:
11+
pull-requests: write
12+
contents: read
13+
14+
jobs:
15+
close-release-prs:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Close PRs for release-* branches
20+
env:
21+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
22+
run: |
23+
echo "Finding open PRs that are for release branches"
24+
25+
prs=$(gh pr list \
26+
--state open \
27+
--json number,headRefName \
28+
--jq '.[] | select(.headRefName | contains("release-")) | .number')
29+
30+
if [ -z "$prs" ]; then
31+
echo "No matching PRs found."
32+
exit 0
33+
fi
34+
35+
for pr in $prs; do
36+
echo "Closing PR #$pr"
37+
gh pr close "$pr" --comment "Automatically closing pull request for release branch."
38+
done
39+

0 commit comments

Comments
 (0)