Skip to content

Merge main into mergeable PRs #121

Merge main into mergeable PRs

Merge main into mergeable PRs #121

name: Merge main into mergeable PRs
on:
push:
branches: [main]
schedule:
- cron: "0 * * * *" # catches PRs approved while already behind main
workflow_dispatch:
concurrency:
group: update-mergeable-prs
cancel-in-progress: false
permissions: {} # uses a PAT so the merge commit triggers CI
jobs:
update-branch:
if: github.repository == 'CherryHQ/cherry-studio'
runs-on: ubuntu-latest
steps:
- name: Merge main into approved PRs whose only blocker is being behind
env:
GH_TOKEN: ${{ secrets.TOKEN_GITHUB_WRITE }}
GH_REPO: ${{ github.repository }}
run: |
gh pr list --base main --state open --limit 100 \
--json number,isDraft,mergeStateStatus,reviewDecision \
--jq '.[] | select(.isDraft == false and .mergeStateStatus == "BEHIND" and .reviewDecision == "APPROVED") | .number' \
| while read -r pr; do
if gh api --method PUT "repos/$GH_REPO/pulls/$pr/update-branch" --silent; then
echo "updated #$pr"
else
echo "could not update #$pr"
fi
done