Skip to content

fix(ci): skip commit when API ref generation produces no changes#655

Open
jlimatampersand wants to merge 1 commit into
mainfrom
fix-gen-ref-empty-commit
Open

fix(ci): skip commit when API ref generation produces no changes#655
jlimatampersand wants to merge 1 commit into
mainfrom
fix-gen-ref-empty-commit

Conversation

@jlimatampersand

Copy link
Copy Markdown
Contributor

Problem

The gen-ref-pages workflow was failing on its Push changes step (e.g. run 29853466481).

The step ran git commit unconditionally after git add src/. When pnpm run generate produced no changes under src/ (the API reference was already up to date), nothing was staged, so git commit exited with code 1 — and because the step shell runs under set -e, the whole job failed.

git add src/
git commit -m "..."
→ no changes added to commit
##[error]Process completed with exit code 1.

Fix

Guard the commit so an empty staged diff is a clean no-op:

git add src/
git diff --cached --quiet || git commit -m "..."

When there are generated changes, it commits and pushes as before. When there aren't, the commit is skipped and the subsequent git push just reports "Everything up-to-date".

🤖 Generated with Claude Code

The gen-ref-pages workflow's "Push changes" step ran `git commit`
unconditionally after `git add src/`. When `pnpm run generate` produced
no changes under src/, nothing was staged and `git commit` exited 1,
failing the job under `set -e`. Guard the commit with
`git diff --cached --quiet ||` so an empty diff is a clean no-op.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant