mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-05-15 17:58:44 +00:00
Add GitHub Actions workflow to enable auto-merge
This commit is contained in:
parent
06fcc7ca81
commit
b3a36b1148
36
.github/workflows/enable-automerge.yml
vendored
Normal file
36
.github/workflows/enable-automerge.yml
vendored
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user