Repository navigation
ci: do not specify checkout ref - #180
Merged
Merged
Conversation
Mirko-A
marked this pull request as draft
September 10, 2026 05:39
Mirko-A
force-pushed
the
mirko/fix-fork-pull-request-ci
branch
from
September 10, 2026 05:52
251191e to
ed08ba2
Compare
The initial checkout uses `ref: ${{ github.head_ref }}`, which expands
to the pull request's source branch name. However, unless specified
otherwise [1], the checkout runs on the base repository, where a fork's
branch may not exist. If a branch with the same name does exist, the
checkout might select unrelated code.
Do not specify checkout ref, so pull request runs check out GitHub's
temporary merge commit, including for pull requests from forks. Push run
behavior remains unchanged.
[1] https://github.com/actions/checkout#usage
Closes: saecki#66
The default pull request checkout uses a temporary merge commit in a detached HEAD state. The CI build job runs type/doc generation, auto-committing generated changes, which requires switching to the source branch [1][2]. This branch may not exist in the base repository for pull requests that originate from forks. If a branch with the same name does exist, it might contain unrelated changes. Only auto-commit on push events. Pushes to branches in this repository, including main after a PR is merged, will continue to generate and commit type/doc updates. [1] https://github.com/stefanzweifel/git-auto-commit-action/blob/92648143fd6aebb695590bfe3fc28f92bcf383e4/entrypoint.sh#L73 [2] https://github.com/stefanzweifel/git-auto-commit-action#checkout-the-correct-branch
Mirko-A
force-pushed
the
mirko/fix-fork-pull-request-ci
branch
from
September 10, 2026 06:44
ed08ba2 to
8e9743c
Compare
Mirko-A
marked this pull request as ready for review
September 10, 2026 07:28
Owner
|
Thanks, that makes sense :) |
Owner
|
Forgot to press merge, haha |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the
head_refcheckout reference in the CI build job, allowing pull request workflow runs to use their default reference which is a temporary merge commit. This fixes CI runs on pull requests that originate from forks, becausehead_refexpands to the PR source branch, which likely does not exist in the base repository (or worse, a branch with the same name exists but contains unrelated changes).Restrict auto-commits to
pushevents only. This prevents pull requests from triggering auto-commit steps that fail when attempting to switch to a PR source branch [1] that exists only on a fork. Generated type/doc changes will continue to get auto-committed on pushes to this repository's branches (includingmain). Pull requests will continue to generate types/docs and run tests.Closes: #66
[1] https://github.com/stefanzweifel/git-auto-commit-action/blob/92648143fd6aebb695590bfe3fc28f92bcf383e4/entrypoint.sh#L73