Skip to content

Checkout fails on forked PRs #2542

@HichemTab-tech

Description

@HichemTab-tech

Inertia adapter(s) affected

  • React
  • Vue 3
  • Svelte
  • Not Applicable

JS package version

NA

Backend stack (optional)

NA

Describe the problem

What happened

The workflow failed during actions/checkout@v4:

git fetch ... origin +refs/heads/add-page-context-to-resolve-component-function* ...
The process '/usr/bin/git' failed with exit code 1

Why

For forked PRs, the branch exists only in the fork, not in inertiajs/inertia.
We were trying to fetch it from the base repo → checkout failed.

Fix

Checkout the PR head repo + commit instead of the base:

- uses: actions/checkout@v4
  with:
    repository: ${{ github.event.pull_request.head.repo.full_name }}
    ref: ${{ github.event.pull_request.head.sha }}

(Universal version for both pushes and PRs:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.sha || github.sha }})

Note

Although this fix unblocks checkout, git-auto-commit-action@v5 may still fail later: the GITHUB_TOKEN is read-only for forks. If we want auto-push on fork PRs, we’ll need to explore a PAT/GitHub App approach.

I'd be happy to open a PR if we agree on the approach.

Steps to reproduce

check #2485

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions