fix(ci): [GitHubActions] CheckoutRef now resolves cross-repo PRs#229
Merged
Conversation
Regression introduced by #175. The generated workflow emitted: - uses: actions/checkout@v6 with: ref: ${{ github.head_ref }} …but didn't set `repository:`. Checkout defaulted to `${{ github.repository }}` (this repo) and tried to resolve `fix/whatever` as a local branch — which fails for fork PRs because the source branch only exists on the contributor's fork. Symptom: cross-repo PRs (e.g. Dennis Doomen's #222 from his fork) fail at the `Run actions/checkout@v6` step with: fatal: A branch or tag with the name 'fix/...' could not be found #175's `CheckoutRef = "${{ github.head_ref }}"` was added so GitVersion / GitRepository.FromLocalDirectory see the source branch in `.git/HEAD` (otherwise checkout puts you on the merge ref in detached-HEAD state). Goal correct; cross-repo coverage missed. Fix: - GitHubActionsCheckoutStep.Write now emits a `repository:` line whenever `Ref` is non-empty: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} The `||` fallback covers push events (no pull_request context). - Doc comments on CheckoutRef + Ref updated. - New regression test case `checkout-ref` in ConfigurationGenerationTest locks the YAML shape. Verified snapshot committed alongside. - .github/workflows/ubuntu-latest.yml regenerated by the build. macos-latest / windows-latest / release.yml unchanged (none set CheckoutRef). - CHANGELOG.md entry under [Unreleased] — 11.0. After this lands, Dennis's PR #222 will pick up the fix on the next workflow run (any rerun, or a push to his branch). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Why
Regression introduced by #175. The `[GitHubActions]` generator emits:
```yaml
with:
ref: ${{ github.head_ref }}
```
…without setting `repository:`. Checkout defaults to `${{ github.repository }}` (this repo) and tries to find the branch by name on `origin`. For PRs from a fork, the source branch only exists on the contributor's fork — checkout fails with:
```
fatal: A branch or tag with the name 'fix/...' could not be found
```
Dennis Doomen's PR #222 (cross-repo, from his fork) hits this on every CI run.
What this PR changes
`src/Fallout.Common/CI/GitHubActions/Configuration/GitHubActionsCheckoutStep.cs` — when `Ref` is set, the generator now also emits:
```yaml
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
```
The `||` fallback handles the three event shapes correctly:
Touch-ups:
Verification
After this PR merges, #222 (Dennis's GitVersion-parse fix) will pick up the corrected workflow on its next CI run — a re-trigger or any new push to his branch.
Refs