ci(digest): use fixed branch with force-push for weekly digest (#44)
Problem: the workflow creates a new dated branch each run. If a digest PR is not merged before the next run, duplicate PRs accumulate. Solution: use a single canonical branch ci/upstream-digest with --force push. Each run resets to main, applies any new items, and force-pushes. If a PR is already open for the branch, GitHub updates it in place. A new PR is only created (with auto-merge) when none exists. The close-stale step is no longer needed.
This commit is contained in:
parent
61e84bbc5f
commit
20bb43057e
1 changed files with 12 additions and 26 deletions
30
.github/workflows/upstream-digest.yml
vendored
30
.github/workflows/upstream-digest.yml
vendored
|
|
@ -15,20 +15,6 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- name: Update upstream tracker
|
||||||
id: digest
|
id: digest
|
||||||
env:
|
env:
|
||||||
|
|
@ -39,23 +25,23 @@ jobs:
|
||||||
if: steps.digest.outputs.changed == 'true'
|
if: steps.digest.outputs.changed == 'true'
|
||||||
run: npx --yes prettier --write doc/upstream.md
|
run: npx --yes prettier --write doc/upstream.md
|
||||||
|
|
||||||
- name: Create PR
|
- name: Push and open PR if needed
|
||||||
if: steps.digest.outputs.changed == 'true'
|
if: steps.digest.outputs.changed == 'true'
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
DATE=$(date +%Y-%m-%d)
|
BRANCH="ci/upstream-digest"
|
||||||
BRANCH="ci/upstream-digest-${DATE}"
|
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git checkout -b "${BRANCH}"
|
git checkout -b "${BRANCH}"
|
||||||
git add doc/upstream.md
|
git add doc/upstream.md
|
||||||
git commit -m "docs(upstream): add digest for week of ${DATE}"
|
git commit -m "docs(upstream): upstream digest $(date +%Y-%m-%d)"
|
||||||
git push origin "${BRANCH}"
|
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 \
|
PR_URL=$(gh pr create \
|
||||||
--title "docs(upstream): add digest for week of ${DATE}" \
|
--title "docs(upstream): upstream digest" \
|
||||||
--body "Automated weekly digest of new upstream activity. Triage by updating statuses and notes." \
|
--body "Automated weekly digest of new upstream activity. Triage by updating statuses and notes." \
|
||||||
--base main \
|
--base main \
|
||||||
--head "${BRANCH}" \
|
--head "${BRANCH}")
|
||||||
--label "upstream/digest")
|
|
||||||
gh pr merge "${PR_URL}" --auto --squash
|
gh pr merge "${PR_URL}" --auto --squash
|
||||||
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue