Skip to content

Commit

Permalink
Create merge-all-prs.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
theballaam96 authored May 17, 2024
1 parent 8192946 commit cad7b8b
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/merge-all-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Auto Merge PRs

on:
workflow_dispatch:

jobs:
auto-merge:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up GitHub CLI
uses: cli/gh-action@v2
with:
version: latest

- name: Fetch pull requests
id: fetch_prs
run: |
gh pr list --state open --json number,labels > pr_list.json
cat pr_list.json
- name: Filter and merge pull requests
id: filter_and_merge
run: |
FORBIDDEN_LABEL="do-not-merge"
PRS=$(jq -c '.[]' pr_list.json)
for PR in $PRS; do
PR_NUMBER=$(echo $PR | jq -r '.number')
LABELS=$(echo $PR | jq -r '.labels[].name')
if echo "$LABELS" | grep -q "$FORBIDDEN_LABEL"; then
echo "PR #$PR_NUMBER has the forbidden label. Skipping merge."
else
echo "Merging PR #$PR_NUMBER"
gh pr merge $PR_NUMBER --merge --auto --delete-branch
fi
done

0 comments on commit cad7b8b

Please sign in to comment.