Skip to content

ci: do not specify checkout ref - #180

Merged
saecki merged 2 commits into
saecki:mainfrom
Mirko-A:mirko/fix-fork-pull-request-ci
Sep 12, 2026
Merged

saecki merged 2 commits into
saecki:mainfrom
Mirko-A:mirko/fix-fork-pull-request-ci

Conversation

@Mirko-A

@Mirko-A Mirko-A commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Removes the head_ref checkout 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, because head_ref expands 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 push events 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 (including main). 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

@Mirko-A
Mirko-A marked this pull request as draft September 10, 2026 05:39
@Mirko-A
Mirko-A force-pushed the mirko/fix-fork-pull-request-ci branch from 251191e to ed08ba2 Compare September 10, 2026 05:52
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
Mirko-A force-pushed the mirko/fix-fork-pull-request-ci branch from ed08ba2 to 8e9743c Compare September 10, 2026 06:44
@Mirko-A
Mirko-A marked this pull request as ready for review September 10, 2026 07:28
@saecki

saecki commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Thanks, that makes sense :)

@saecki
saecki merged commit 7039bc1 into saecki:main Sep 12, 2026
1 check passed
@saecki

saecki commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Forgot to press merge, haha

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.

Figure out why CI is broken on PRs by contributors other than me

2 participants