Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking out 'head_ref' doesn't work anymore #275

Closed
Smana opened this issue Jun 13, 2020 · 4 comments
Closed

Checking out 'head_ref' doesn't work anymore #275

Smana opened this issue Jun 13, 2020 · 4 comments

Comments

@Smana
Copy link

Smana commented Jun 13, 2020

Hi everyone,

I was using the following configuration to checkout the proper branch in order to use it with another action 'git-auto-commit'.

 on:                                                                                                                                                                                                               
   pull_request:                                                                                                                                                                                                   
     branches: [master]                                                                                                                                                                                            
                                                                                                                                                                                                                   
 jobs:                                                                                                                                                                                                             
   build:                                                                                                                                                                                                          
     runs-on: ubuntu-latest                                                                                                                                                                                        
     steps:                                                                                                                                                                                                        
       - uses: actions/checkout@v2                                                                                                                                                                                 
         with:                                                                                                                                                                                                     
           ref: ${{ github.head_ref }} 
...

Since a few days, this doesn't work anymore. I got the following errors:

   /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/ska/checkout_github.head_ref*:refs/remotes/origin/ska/checkout_github.head_ref* +refs/tags/ska/checkout_github.head_ref*:refs/tags/ska/checkout_github.head_ref*
  ##[error]The process '/usr/bin/git' failed with exit code 1

This is a public repository for tests purposes so please have a look here : https://github.com/Smana/gh-actions-gitops/actions

Let me know if you need further details.
Thanks

@ericsciple
Copy link
Contributor

Can you try setting the following env vars so fetch will print more info:

GITHUB_TRACE=1
GIT_CURL_VERBOSE=1

For example:

jobs:
  foo:
    steps:
      - uses: actions/checkout@v2
        env:
          GIT_TRACE: 1
          GIT_CURL_VERBOSE: 1

@Smana
Copy link
Author

Smana commented Jun 23, 2020

Hi @ericsciple, thanks for the answer and sorry for the delay. Here are the error logs when adding the env vars you mentionned.

Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/ska/verbose_gh_checkout*:refs/remotes/origin/ska/verbose_gh_checkout* +refs/tags/ska/verbose_gh_checkout*:refs/tags/ska/verbose_gh_checkout*
  19:06:20.402264 git.c:442               trace: built-in: git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin '+refs/heads/ska/verbose_gh_checkout*:refs/remotes/origin/ska/verbose_gh_checkout*' '+refs/tags/ska/verbose_gh_checkout*:refs/tags/ska/verbose_gh_checkout*'
  19:06:20.402506 run-command.c:663       trace: run_command: GIT_DIR=.git git-remote-https origin https://github.com/Smana/gh-actions-gitops
  * Couldn't find host github.com in the .netrc file; using defaults
  *   Trying 140.82.113.3...
  * TCP_NODELAY set
  * Connected to github.com (140.82.113.3) port 443 (#0)
  * found 127 certificates in /etc/ssl/certs/ca-certificates.crt
  * found 383 certificates in /etc/ssl/certs
  * ALPN, offering http/1.1
  * SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
  * 	 server certificate verification OK
  * 	 server certificate status verification SKIPPED
  * 	 common name: github.com (matched)
  * 	 server certificate expiration date OK
  * 	 server certificate activation date OK
  * 	 certificate public key: RSA
  * 	 certificate version: #3
  * 	 subject: C=US,ST=California,L=San Francisco,O=GitHub\, Inc.,CN=github.com

@Smana
Copy link
Author

Smana commented Jun 30, 2020

Actually removing the protection on master branch did the trick. For the moment I don't know why. I'll open an issue or reopen that one if necessary. If I have any other info I'll let you know

@Smana Smana closed this as completed Jun 30, 2020
hughrun added a commit to hughrun/public_library_map that referenced this issue Feb 2, 2021
remove `head_ref` reference from actions/checkout to resolve error (see actions/checkout#275)
@0ptim
Copy link

0ptim commented Feb 5, 2023

Hey @Smana sorry for bothering.
But I'm facing a similar issue where using head_ref to check out does not work if someone makes a PR from a forked repo onto main in my repo.

      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
          fetch-depth: 0

This fails with: A branch or tag with the name 'patch-1' could not be found. Was that all you had to do?

I removed the branch protection on main, but this does not change anything.


Just got it working! 🎉
Have a look here: #455

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants