Bulk Merge PRs #219
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: "Bulk Merge PRs" | |
on: | |
workflow_dispatch: | |
inputs: | |
dryRun: | |
description: Dry Run | |
default: "false" | |
required: false | |
labels: | |
description: Labels | |
default: "any" | |
required: false | |
jobs: | |
bulk-merge-prs: | |
name: Bulk Merge PRs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate Token | |
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1 | |
id: app-token | |
with: | |
app-id: "${{ secrets.BOT_APP_ID }}" | |
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
with: | |
token: "${{ steps.app-token.outputs.token }}" | |
- name: Merge | |
shell: bash | |
env: | |
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}" | |
run: | | |
args=() | |
args+=(--state open) | |
args+=(--search "-label:hold") | |
args+=(--search "-label:type/major") | |
if [ "${{ github.event.inputs.labels }}" != "any" ]; then | |
IFS=',' read -ra labels <<< "${{ github.event.inputs.labels }}" | |
for label in "${labels[@]}"; do | |
args+=(--label "${label}") | |
done | |
fi | |
for id in $(gh pr list "${args[@]}" --jq '.[].number' --json number); do | |
if [ "${{ github.event.inputs.dryRun }}" = "true" ]; then | |
echo "Dry run: gh pr merge $id --squash" | |
continue | |
fi | |
gh pr merge "${id}" --squash | |
sleep 2 | |
done |