checkout@v1 does not checkout the forked repo in pull request

Created on 4 May 2020  路  10Comments  路  Source: actions/checkout

An external contributor has opened a pull request to our repo. But it seems that instead of checking out the forked repo, checkout@v1 is cloning the main repo and then fails to find the commit for the pr. See details here:

How do I fix this?

All 10 comments

Similar issue here, however with checkout@v2
https://github.com/Milano-R/erum2020-covidr-contest/pull/20/checks?check_run_id=642113150
(if it matters, this is a re-run of a failed job)

Checking out the ref
  /usr/bin/git checkout --progress --force -B master refs/remotes/origin/master
  Reset branch 'master'

Note also that the checkout actually includes the commits from the forked repo, so it seems to be an issue of having the wrong refs

Compare to another pull request using the very same workflow just 2 days ago
https://github.com/Milano-R/erum2020-covidr-contest/pull/17/checks?check_run_id=638697743

Checking out the ref
  /usr/bin/git checkout --progress --force refs/remotes/pull/17/merge
  Note: switching to 'refs/remotes/pull/17/merge'.

This is potentially very unsafe for workflows using the refs to perform conditional steps on master

Hoping this can help, here are the links of two re-runs of for the same PR:

@riccardoporreca are you still hitting this issue today? I opened a fork PR against your repo but looks like working correctly now. In the github context, ref is correctly showing as "refs/pull/25/merge" now.

@tamalsaha i tested against stashed/postgres too and appears to be working now too

@ericsciple, thanks. I can confirm the issue does not appear any longer for new workflow runs (I have been successfully opening new PRs and did not see it happening any longer).

Re-running the same failed workflow for the PR mentioned above still has the same issue:
https://github.com/Milano-R/erum2020-covidr-contest/pull/15/checks?check_run_id=646513906
but I am confident that this will not occur for new runs

If the initial CI run fail and then you retry from the GitHub actions UI, does it still work properly?

In this case, i dont think retry will help because the ref name in the payload was wrong. Should work for new fork PRs.

@ericsciple, I see this happening in sort of a systematic way, in that re-runs of workflows on PRs get the wrong refs.

I have reproduced this with your workflow file in my own fork https://github.com/riccardoporreca/erum2020-covidr-contest/tree/test-gh-context, forcing it to always fail to allow a re-run.

I know there are also issues with the cache actions on PRs upon re-runs, see https://github.com/actions/cache/issues/208#issuecomment-596664572. Perhaps the root cause is the same.

Hope this helps.

@riccardoporreca thanks! Good find. I was able to locate the corresponding issue internally... looks like it's being worked on.

Working like a charm now (https://github.com/actions/cache/issues/208#issuecomment-630896455)
https://github.com/Milano-R/erum2020-covidr-contest/pull/51/checks?check_run_id=689705978

Sounds like the two issues are fixed now. Let me know or reopen if otherwise

Was this page helpful?
0 / 5 - 0 ratings