This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (52 loc) · 1.6 KB
/
bulk-merge-prs.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
---
# 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@v1
id: app-token
with:
app-id: "${{ secrets.BOT_APP_ID }}"
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Checkout
uses: actions/checkout@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