Skip to content

Commit 28c4a07

Browse files
committed
feat(workflow): Create workflow that cleans up and closes PRS
Konflux continues to generate PRs for old release branches. This is becacause the renovate config is on main and the older release branches cannot get these changes merged, or a release will occur. This workflow will auto-close those PRs and any new PRs generated for release branches. Signed-off-by: Bryan Ramos <bramos@redhat.com>
1 parent 6c0e691 commit 28c4a07

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+
permission:
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.GITHUB_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)