Skip to content

Auto Merge PRs

Auto Merge PRs #5

Workflow file for this run

name: Auto Merge PRs
on:
workflow_dispatch:
jobs:
auto-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Fetch pull requests
id: fetch_prs
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FORBIDDEN_LABEL="batch-merge-ignore"
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
else
echo "Merging PR #$PR_NUMBER"
fi
done