Skip to content

Commit e35f776

Browse files
authored
ci(format): fix checkout for fork PRs (CopilotKit#5164)
## Problem The `format` job sets `ref: github.head_ref` but leaves `repository:` unset, so it checks the head branch out of the **base** repo. For fork PRs the head branch only exists on the fork, so checkout fails before formatting even runs. Seen on CopilotKit#5099 (fork PR, branch `fix/5072`): ``` ##[error]A branch or tag with the name 'fix/5072' could not be found ``` ## Fix Resolve `repository` to the head repo on PRs, matching `ref`: ```yaml ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }} ``` Same-repo PRs are unchanged (head repo == base repo), so the auto-format push-back still works.
2 parents c6d71e9 + 27ff268 commit e35f776

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

.github/workflows/static_quality.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ jobs:
4040
with:
4141
persist-credentials: false
4242
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
43+
# Check the head branch out from the head repo, not the base repo.
44+
# For fork PRs the head branch only exists on the fork, so defaulting
45+
# to the base repo makes checkout fail with "a branch or tag with the
46+
# name '<branch>' could not be found". Same-repo PRs resolve to the
47+
# base repo unchanged, so the auto-format push-back below still works.
48+
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
4349
token: ${{ secrets.GITHUB_TOKEN }}
4450
# Full history so we can diff HEAD against the current base branch
4551
# tip to scope the formatter to PR-changed files.

0 commit comments

Comments
 (0)