Add GitHub Actions workflow to enable auto-merge

This commit is contained in:
Weltenbummler397 2026-05-04 09:28:24 +02:00 committed by GitHub
parent 06fcc7ca81
commit b3a36b1148
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

36
.github/workflows/enable-automerge.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Enable auto-merge for open PRs
on:
workflow_dispatch: {}
pull_request:
types: [opened, reopened,ready_for_review]
permissions:
contents: write
pull-requests: write
jobs:
enable:
runs-on: ubuntu-latest
steps:
- name: Enable auto-merge for all open PRs (and the current one)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
echo "Listing open PRs in $REPO..."
prs=$(gh pr list --repo "$REPO" --state open --json number --jq '.[].number')
if [ -z "$prs" ]; then
echo "No open PRs."
exit 0
fi
for pr in $prs; do
echo "Enabling auto-merge for PR #$pr"
# Choose merge strategy: --merge | --squash | --rebase
# Use --merge here; change if you prefer squash:
gh pr merge "$pr" --repo "$REPO" --auto --merge || true
done