Skip to content

Commit 304b00e

Browse files
Daniel Jonesclaude
andcommitted
revert(ci): use peter-evans/create-pull-request for refresh PR
Reverts the gh + native git workflow back to peter-evans/create-pull-request@v6. The append-commits design was tempting but the single-squash-commit model that peter-evans provides is the better fit here: - When the responses are unchanged across runs, peter-evans diffs tree (not commit SHA), so identical content -> no push, no PR churn. The branch sits untouched even though the locally computed commit would have a fresh timestamp. - When the responses change, the branch is force-pushed with a new single commit. The diff against main always reflects the latest API state in one reviewable chunk, instead of accumulating a growing chain of incremental refresh commits. - When the responses match main (typically after the PR has been merged), peter-evans automatically closes the PR and deletes the branch. Kept from the previous iteration: the concurrency group so cron and manual workflow_dispatch runs cannot race, and the comment documenting the manual trigger. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent add5c86 commit 304b00e

1 file changed

Lines changed: 22 additions & 82 deletions

File tree

.github/workflows/refresh-v3-languages.yml

Lines changed: 22 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -15,96 +15,36 @@ concurrency:
1515
group: refresh-v3-languages
1616
cancel-in-progress: false
1717

18-
env:
19-
REFRESH_BRANCH: chore/refresh-v3-languages
20-
COMMIT_PATHS: data/v3-languages
21-
2218
jobs:
2319
refresh:
24-
name: Fetch and update refresh PR
20+
name: Fetch and open PR on diff
2521
runs-on: ubuntu-latest
2622
steps:
27-
- name: Checkout main
23+
- name: Checkout
2824
uses: actions/checkout@v5
29-
with:
30-
fetch-depth: 0
31-
32-
- name: Detect existing refresh PR
33-
id: pr
34-
env:
35-
GH_TOKEN: ${{ github.token }}
36-
run: |
37-
number=$(gh pr list \
38-
--base main \
39-
--head "$REFRESH_BRANCH" \
40-
--state open \
41-
--json number \
42-
--jq '.[0].number // ""')
43-
echo "number=$number" >> "$GITHUB_OUTPUT"
44-
if [ -n "$number" ]; then
45-
echo "Existing refresh PR: #$number"
46-
else
47-
echo "No existing refresh PR"
48-
fi
49-
50-
- name: Check out existing refresh branch
51-
if: steps.pr.outputs.number != ''
52-
run: |
53-
git fetch origin "$REFRESH_BRANCH"
54-
git checkout -B "$REFRESH_BRANCH" "origin/$REFRESH_BRANCH"
5525

5626
- name: Fetch latest /v3/languages responses
5727
env:
5828
DEEPL_AUTH_KEY: ${{ secrets.DEEPL_API_KEY }}
5929
run: python3 scripts/fetch_v3_languages.py
6030

61-
- name: Detect content changes
62-
id: diff
63-
run: |
64-
if git diff --quiet -- $COMMIT_PATHS; then
65-
echo "changed=false" >> "$GITHUB_OUTPUT"
66-
echo "No changes in $COMMIT_PATHS; nothing to commit."
67-
else
68-
echo "changed=true" >> "$GITHUB_OUTPUT"
69-
fi
70-
71-
- name: Configure git author
72-
if: steps.diff.outputs.changed == 'true'
73-
run: |
74-
git config user.name "github-actions[bot]"
75-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
76-
77-
- name: Append commit to existing refresh PR
78-
if: steps.diff.outputs.changed == 'true' && steps.pr.outputs.number != ''
79-
env:
80-
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
81-
run: |
82-
git add -- $COMMIT_PATHS
83-
git commit -m "chore(v3-languages): refresh vended responses
84-
85-
Run: $RUN_URL"
86-
git push origin "$REFRESH_BRANCH"
87-
88-
- name: Create new refresh PR
89-
if: steps.diff.outputs.changed == 'true' && steps.pr.outputs.number == ''
90-
env:
91-
GH_TOKEN: ${{ github.token }}
92-
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
93-
run: |
94-
git checkout -b "$REFRESH_BRANCH"
95-
git add -- $COMMIT_PATHS
96-
git commit -m "chore(v3-languages): refresh vended responses
97-
98-
Run: $RUN_URL"
99-
git push -u origin "$REFRESH_BRANCH"
100-
gh pr create \
101-
--base main \
102-
--head "$REFRESH_BRANCH" \
103-
--title "chore(v3-languages): refresh vended responses" \
104-
--body "Automated refresh of \`data/v3-languages/\` from \`https://api.deepl.com/v3/languages\`, opened by the \`refresh-v3-languages\` workflow.
105-
106-
Subsequent runs append new commits to this PR when the responses change again, so the diff against \`main\` represents the cumulative update. Review the latest state and merge when ready.
107-
108-
First run: $RUN_URL" \
109-
--label automated \
110-
--label v3-languages
31+
- name: Open or update refresh PR
32+
uses: peter-evans/create-pull-request@v6
33+
with:
34+
branch: chore/refresh-v3-languages
35+
base: main
36+
commit-message: "chore(v3-languages): refresh vended responses"
37+
title: "chore(v3-languages): refresh vended responses"
38+
body: |
39+
Automated refresh of `data/v3-languages/` from `https://api.deepl.com/v3/languages`,
40+
opened by the `refresh-v3-languages` workflow.
41+
42+
This PR is rewritten in place on each run: if the vended responses change again
43+
before merge, the branch is force-pushed with a new single squashed commit so the
44+
diff against `main` always reflects the latest API state. If a run finds the
45+
responses identical to what is already on the branch, the branch is left untouched.
46+
If a run finds the responses match `main` (e.g. the PR was merged), this PR is
47+
closed and the branch deleted automatically.
48+
add-paths: data/v3-languages/**
49+
delete-branch: true
50+
labels: automated, v3-languages

0 commit comments

Comments
 (0)