Problem: if a digest PR is not merged before the next weekly run, a second PR is created for the same items plus any new ones, leading to duplicate open PRs. Solution: before fetching upstream activity, close any open PRs labeled upstream/digest (deleting their branches). The new run re-fetches all items since the last merged baseline and produces a single up-to-date PR.
61 lines
1.8 KiB
YAML
61 lines
1.8 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: Close existing digest PRs
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
gh pr list \
|
|
--repo barrettruth/canola.nvim \
|
|
--label "upstream/digest" \
|
|
--state open \
|
|
--json number \
|
|
--jq '.[].number' \
|
|
| xargs -r -I{} gh pr close {} \
|
|
--repo barrettruth/canola.nvim \
|
|
--delete-branch
|
|
|
|
- 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: Create PR
|
|
if: steps.digest.outputs.changed == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
DATE=$(date +%Y-%m-%d)
|
|
BRANCH="ci/upstream-digest-${DATE}"
|
|
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): add digest for week of ${DATE}"
|
|
git push origin "${BRANCH}"
|
|
PR_URL=$(gh pr create \
|
|
--title "docs(upstream): add digest for week of ${DATE}" \
|
|
--body "Automated weekly digest of new upstream activity. Triage by updating statuses and notes." \
|
|
--base main \
|
|
--head "${BRANCH}" \
|
|
--label "upstream/digest")
|
|
gh pr merge "${PR_URL}" --auto --squash
|