Skip to content

Close release-* PRs #48

Close release-* PRs

Close release-* PRs #48

Workflow file for this run

name: Close release-* PRs
on:
# Manual
workflow_dispatch:
schedule:
# Run daily at 2am UTC
- cron: "0 2 * * *"
permissions:
pull-requests: write
contents: read
jobs:
close-release-prs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Close PRs for release-* branches
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
set -euo pipefail
LIMIT=50
echo "Finding open PRs that are for release branches"
# Get all PRs trying to merge into a 'release-*' branch.
prs=$(gh pr list \
--state open \
--limit 500 \
--json number,baseRefName \
--jq '.[] | select(.baseRefName | contains("release-")) | .number')
if [ -z "$prs" ]; then
echo "No matching PRs found."
exit 0
fi
count=$(echo "$prs" | wc -w | tr -d ' ')
echo "Found $count release-* PR(s) to close."
for pr in $prs; do
echo "Closing PR #$pr"
gh pr close "$pr" --comment "Automatically closing pull request for release branch."
done