Skip to content

Commit 18ffb49

Browse files
rdimitrovclaude
andauthored
Fix retry-mode git context + push refresh commit immediately (#761)
Two bugs from the first real Renovate run (#759) and its retry: 1. workflow_dispatch retry failed at "Resolve PR number and head ref" with "failed to run git: fatal: not a git repository". The step runs BEFORE actions/checkout, so `gh pr view` has no git context to infer the repo from. Added `--repo "$GITHUB_REPOSITORY"` to the three gh pr view calls that run pre-checkout (HEAD_REF + AUTHOR in the retry branch of step "pr", plus BASE in the retry branch of step "eff"). The error message we initially saw ("author ... is not an accepted bot") was just the shell source being echoed by `bash -x`-like output; the actual runtime never got to that point. 2. The refresh commit (~38 files, reference-asset regeneration) was only pushed at the END of the workflow, after the skill. When the skill failed or was cancelled — which it did repeatedly today — the refresh commit died with the runner and PRs ended up with only the one-line YAML bump. Now push the refresh commit as soon as it's created, so the reference-asset work lands on the PR branch independent of skill outcome. This was a pending commit that got orphaned by #760's squash-merge; re-shipping. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d473634 commit 18ffb49

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

.github/workflows/upstream-release-docs.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,11 @@ jobs:
111111
workflow_dispatch)
112112
if [ -n "$DISPATCH_PR" ]; then
113113
PR_NUMBER="$DISPATCH_PR"
114-
HEAD_REF=$(gh pr view "$PR_NUMBER" --json headRefName --jq .headRefName)
115-
AUTHOR=$(gh pr view "$PR_NUMBER" --json author --jq '.author.login')
114+
# --repo is required because this step runs before the
115+
# actions/checkout below — gh otherwise looks for a
116+
# local .git context and fails with "not a git repository".
117+
HEAD_REF=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json headRefName --jq .headRefName)
118+
AUTHOR=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json author --jq '.author.login')
116119
case "$AUTHOR" in
117120
app/renovate|renovate[bot]|app/github-actions|github-actions[bot])
118121
;;
@@ -235,9 +238,10 @@ jobs:
235238
BASE="$BASE_FROM_EVENT"
236239
else
237240
# workflow_dispatch retry: look up the PR's base_ref.
241+
# --repo because in retry mode there's no prior checkout.
238242
NUMBER="$PR_FROM_RESOLVE"
239243
HEAD="$HEAD_FROM_RESOLVE"
240-
BASE=$(gh pr view "$NUMBER" --json baseRefName --jq .baseRefName)
244+
BASE=$(gh pr view "$NUMBER" --repo "$GITHUB_REPOSITORY" --json baseRefName --jq .baseRefName)
241245
fi
242246
{
243247
echo "number=$NUMBER"
@@ -344,21 +348,26 @@ jobs:
344348
node scripts/bundle-upstream-schema.mjs
345349
rm -rf "$TMP"
346350
347-
# Commit the refreshed reference assets (synced release-asset
348-
# files + regenerated toolhive CRD MDX if applicable) before the
349-
# skill runs. This keeps the skill's content commit clean and
351+
# Commit AND PUSH the refreshed reference assets (synced release-
352+
# asset files + regenerated toolhive CRD MDX if applicable) before
353+
# the skill runs. Pushing here — rather than batching the push
354+
# with the skill-content commit later — means refresh work is
355+
# preserved on the PR even if the skill step fails or is
356+
# cancelled. Also keeps the skill's content commit clean and
350357
# lets the autogen-detect step below distinguish skill touches
351358
# from our own legitimate refresh writes.
352-
- name: Commit refreshed reference assets
359+
- name: Commit + push refreshed reference assets
353360
env:
354361
PROJECT_ID: ${{ steps.detect.outputs.id }}
355362
NEW_TAG: ${{ steps.detect.outputs.new_tag }}
363+
HEAD_REF: ${{ steps.eff.outputs.head_ref }}
356364
run: |
357365
git add -A
358366
if git diff --cached --quiet; then
359367
echo "No reference changes for $PROJECT_ID $NEW_TAG."
360368
else
361369
git commit -m "Refresh reference assets for $PROJECT_ID $NEW_TAG"
370+
git push origin "HEAD:$HEAD_REF"
362371
fi
363372
364373
- name: Extract reviewers from release compare

0 commit comments

Comments
 (0)