actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.83k stars 1.72k forks source link

`origin/HEAD` Not Present #910

Open Kurt-von-Laven opened 2 years ago

Kurt-von-Laven commented 2 years ago

origin/HEAD is a useful ref since it refers to the default branch, which varies between repos. origin/HEAD is normally present locally, so Git scripts, hooks, etc. that work locally sometimes rely on the presence of origin/HEAD and then break in GitHub Actions. I'm not aware of an input that allows one to ensure that this useful ref is present in a checkout. As a workaround, we run git remote set-head origin --auto manually, but it would be nice to have within the action since diagnosing the issue requires considerable familiarity with Git. In particular, I find the absence of origin/HEAD when passing fetch-depth: 0 counterintuitive.

jasonkarns commented 11 months ago

co-signed. We're running into this with a rake task of ours:

git diff --exit-code origin/HEAD -- /home/runner/work/depot/depot/db/vtiger_structure.sql
fatal: bad revision 'origin/HEAD'

And to be clear, this is with a "full history" checkout:

    steps:
      - uses: actions/checkout@v3
        with: {fetch-depth: 0} # need history for git-diffing
jasonkarns commented 4 months ago

Bump on this.

Was hoping to use the origin/${{github.base_ref || 'HEAD^'}} in a workflow that could be run on PR or push events; but origin/HEAD is still not present after checkout.