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

Tag is fetched but checkout complains for not existing ref #1668

Open
giohappy opened this issue Mar 29, 2024 · 2 comments
Open

Tag is fetched but checkout complains for not existing ref #1668

giohappy opened this issue Mar 29, 2024 · 2 comments

Comments

@giohappy
Copy link

giohappy commented Mar 29, 2024

In my action, I need to checkout an external repository.
It works well if I checkout branches, but it fails with tags.

This is the configuration, which references this tag :

- uses: actions/checkout@v4
  with:
	repository: 'geoserver/geoserver'
	ref: ${{ github.ref }}
	fetch-tags: 'true'
	path: 'geoserver'

and this is the error:

Run actions/checkout@v4
Syncing repository: geoserver/geoserver
Getting Git version info
Temporarily overriding HOME='/home/runner/work/_temp/acac2333-334b-4142-adb2-0c290c9f6b17' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
/usr/bin/git config --global --add safe.directory /home/runner/work/geoserver-geonode-ext/geoserver-geonode-ext/geoserver
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules --depth=1 origin +refs/heads/2.24.2:refs/remotes/origin/2.24.2
  Error: fatal: couldn't find remote ref refs/heads/2.24.2
  The process '/usr/bin/git' failed with exit code 128
  Waiting 16 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules --depth=1 origin +refs/heads/2.24.2:refs/remotes/origin/2.24.2
  Error: fatal: couldn't find remote ref refs/heads/2.24.2
  The process '/usr/bin/git' failed with exit code 128
  Waiting 12 seconds before trying again
  /usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules --depth=1 origin +refs/heads/2.24.2:refs/remotes/origin/2.24.2
  Error: fatal: couldn't find remote ref refs/heads/2.24.2
  Error: The process '/usr/bin/git' failed with exit code 128

Notice that even if I use fetch-depth > 1 the error still happens

@angus-longmore-acc
Copy link

angus-longmore-acc commented Apr 15, 2024

What branch/tag is triggering the workflow? i.e. what is the content of {{ github.ref }} ?
The logs imply that it is a branch named 2.24.2.
If its refs/heads/2.24.2, you should instead have it as refs/tags/2.25.0

@cory-miller
Copy link
Contributor

cory-miller commented Apr 25, 2024

github.ref is going to be the fully formed ref that caused the workflow to run. If you want this to then checkout a tag, it would have to be a workflow run that triggered off a tag (such as pushing to that tag). Assuming the repository with the workflow has the same tag as geoserver/geoserver then this should be work by pushing 2.24.2 tag to the other repository. Based on the logs you provided, it looks like instead the other repository has a branch named 2.24.2 that caused the workflow to trigger. Is that the case?

You can consider using github.ref_name instead if you want to trigger off changes to a branch name that matches tags in geoserver/geoserver. actions/checkout should try both refs/heads and refs/tags:

checkout/src/ref-helper.ts

Lines 104 to 109 in 8459bc0

else if (!upperRef.startsWith('REFS/')) {
return [
`+refs/heads/${ref}*:refs/remotes/origin/${ref}*`,
`+refs/tags/${ref}*:refs/tags/${ref}*`
]
}

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