Skip to content

ci(attest): push the rebuilt dist to the PR branch by name - #136

Closed
ronens88 wants to merge 2 commits into
mainfrom
ci/rebuild-dist-push
Closed

ronens88 wants to merge 2 commits into
mainfrom
ci/rebuild-dist-push

Conversation

@ronens88

@ronens88 ronens88 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The rebuild-dist job checks out the PR head SHA, so the working copy is a detached HEAD. When attest/dist/index.js was out of date, the auto-commit step then ran a bare git push, which exits with fatal: You are not currently on a branch (seen on #135). Authors had to rebuild and commit the bundle by hand.

Changes

  • The auto-commit step pushes to the PR branch by name, leased on the PR head SHA the run built from: git push --force-with-lease="refs/heads/$PR_HEAD_REF:$PR_HEAD_SHA" origin "HEAD:refs/heads/$PR_HEAD_REF". Both values come from github.event.pull_request.head through env:. The push lands only while the branch still points at that SHA; if it moved forward, was reset to an earlier commit, or was deleted during the run, the push is rejected.
  • The workflow also runs when .github/workflows/build-attest-dist.yaml changes, so edits to it are exercised on their own PR.
  • The fork guard and the "exactly one changed file" check are unchanged.

Validation

The step script was extracted from the workflow and run against a local repository, checked out at a detached PR head with the bundle rebuilt:

Case Exit Result
Previous step 128 You are not currently on a branch
This change 0 Bot commit pushed to the PR branch
This change, PR branch moved forward after checkout 1 Push rejected (stale info), branch unchanged
This change, PR branch reset to an earlier commit 1 Push rejected, branch unchanged (a plain push landed here)
This change, PR branch deleted 1 Push rejected, branch stays deleted (a plain push recreated it)
This change, bundle already in sync 0 dist already up to date

On this PR the workflow runs because the workflow file changed, and the bundle is already in sync, so it exits early. The push path runs on the next PR that changes attest/index.js without committing the bundle.

Note: a push made with GITHUB_TOKEN does not start new workflow runs, so the bot commit carries no checks of its own. Push another commit, or re-run the workflows, if checks are needed on it.

🤖 Generated with Claude Code

The rebuild job checks out the PR head SHA, which leaves a detached
HEAD, so the bare `git push` in the auto-commit step exited with "You
are not currently on a branch". Push HEAD to the PR branch explicitly.
A branch that moved since the run started is rejected as
non-fast-forward instead of being overwritten.

Also run the workflow when the workflow file itself changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T12:32:59.216971Z c93dfcd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c93dfcde49

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Lease the push on the PR head SHA the run built from. A plain push still
landed when the branch was reset to an ancestor or deleted during the
run; with the lease, any change to the branch rejects the push.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ronens88

Copy link
Copy Markdown
Contributor Author

Folded into #135 (commit 9208aa0), which now carries this workflow change with the lease on the PR head SHA.

@ronens88 ronens88 closed this Oct 26, 2026
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