Auto Merge PRs #7
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
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 | |
echo "Skipping PR $PR_NUMBER" | |
else | |
echo "Merging PR #$PR_NUMBER" | |
fi | |
done | |