Replace the approve-only automatic-approval workflow with a combined approve + enable-auto-merge workflow that also re-runs on every push, plus a scheduled reconcile job that re-enables auto-merge for prepared bot PRs if GitHub ever disables it. Bot PRs are gated to the known bot actors, same-repo head, and base branch dev.
41 lines
1.5 KiB
YAML
41 lines
1.5 KiB
YAML
name: "[Bots] Reconcile Auto-merge"
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "*/30 * * * *"
|
|
workflow_dispatch:
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
reconcile:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Obtain token
|
|
id: obtainToken
|
|
uses: actions/create-github-app-token@v3
|
|
with:
|
|
private-key: ${{ secrets.RENOVATE_APPROVE_PRIVATE_KEY }}
|
|
client-id: ${{ secrets.RENOVATE_APPROVE_APP_ID }}
|
|
permission-pull-requests: write # required to enable auto-merge
|
|
|
|
- name: Install GitHub CLI
|
|
run: sudo apt-get install -y gh
|
|
|
|
- name: Re-enable auto-merge for prepared bot PRs
|
|
env:
|
|
GITHUB_TOKEN: ${{ steps.obtainToken.outputs.token }}
|
|
run: |
|
|
# 158783068: homarr-renovate[bot]
|
|
# 190541745: homarr-crowdin[bot]
|
|
# 210161987: homarr-update-contributors[bot]
|
|
# 175441: homarr-releases[bot]
|
|
gh pr list --repo "${{ github.repository }}" --base dev --state open --limit 100 \
|
|
--json number,author,reviewDecision,mergeStateStatus,autoMergeRequest \
|
|
--jq '.[] | select(IN(.author.login; "renovate[bot]", "homarr-crowdin[bot]", "homarr-update-contributors[bot]", "homarr-releases[bot]")) | select(.reviewDecision == "APPROVED") | select(.mergeStateStatus == "CLEAN") | select(.autoMergeRequest == null) | .number' \
|
|
| while read -r pr; do
|
|
echo "Re-enabling auto-merge on PR #$pr"
|
|
gh pr merge "$pr" --auto --squash --delete-branch
|
|
done
|