canola.nvim/.github/workflows/upstream-digest.yml
Barrett Ruth 71b51746af
ci(digest): auto-approve digest PRs via PAT to satisfy review requirement (#46)
Problem: the main branch ruleset requires 1 approving review, which
blocks auto-merge. The GITHUB_TOKEN cannot approve its own PR.

Solution: after creating the PR, approve it using DIGEST_PAT (a
fine-grained PAT stored as a repo secret), then enable auto-merge.
The approval comes from a different actor than the bot, satisfying
require_last_push_approval.
2026-03-03 15:18:20 -05:00

48 lines
1.6 KiB
YAML

name: upstream digest
on:
schedule:
- cron: "0 9 * * 1"
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
digest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update upstream tracker
id: digest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python3 .github/scripts/upstream_digest.py
- name: Format doc/upstream.md
if: steps.digest.outputs.changed == 'true'
run: npx --yes prettier --write doc/upstream.md
- name: Push and open PR if needed
if: steps.digest.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH="ci/upstream-digest"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${BRANCH}"
git add doc/upstream.md
git commit -m "docs(upstream): upstream digest $(date +%Y-%m-%d)"
git push --force origin "${BRANCH}"
if ! gh pr list --head "${BRANCH}" --state open --json number --jq '.[0].number' | grep -q .; then
PR_URL=$(gh pr create \
--title "docs(upstream): upstream digest" \
--body "Automated weekly digest of new upstream activity. Triage by updating statuses and notes." \
--base main \
--head "${BRANCH}")
GH_TOKEN="${{ secrets.DIGEST_PAT }}" gh pr review "${PR_URL}" --approve
gh pr merge "${PR_URL}" --auto --squash
fi