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

Can't fetch with fetch-tags when triggered by tag #1467

Open
Molkree opened this issue Sep 6, 2023 · 7 comments
Open

Can't fetch with fetch-tags when triggered by tag #1467

Molkree opened this issue Sep 6, 2023 · 7 comments

Comments

@Molkree
Copy link

Molkree commented Sep 6, 2023

Getting the following error:
Error: fatal: Cannot fetch both <sha> and refs/tags/<tag> to refs/tags/<tag>

Example workflow:

name: Release

on:
  workflow_dispatch:
  # Triggers the workflow on tag events
  push:
    tags: '*'

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 250
          fetch-tags: true

Example of a failing run.

Raw log
2023-09-06T20:54:11.5281780Z Requested labels: ubuntu-latest
2023-09-06T20:54:11.5282085Z Job defined at: Molkree/github_actions/.github/workflows/workflow.yml@refs/tags/V1
2023-09-06T20:54:11.5282200Z Waiting for a runner to pick up this job...
2023-09-06T20:54:12.2788574Z Job is waiting for a hosted runner to come online.
2023-09-06T20:54:15.6896729Z Job is about to start running on the hosted runner: GitHub Actions 2 (hosted)
2023-09-06T20:54:17.8444082Z Current runner version: '2.308.0'
2023-09-06T20:54:17.8473502Z ##[group]Operating System
2023-09-06T20:54:17.8474111Z Ubuntu
2023-09-06T20:54:17.8474513Z 22.04.3
2023-09-06T20:54:17.8474765Z LTS
2023-09-06T20:54:17.8475076Z ##[endgroup]
2023-09-06T20:54:17.8475431Z ##[group]Runner Image
2023-09-06T20:54:17.8475752Z Image: ubuntu-22.04
2023-09-06T20:54:17.8476128Z Version: 20230821.1.0
2023-09-06T20:54:17.8476673Z Included Software: https://github.com/actions/runner-images/blob/ubuntu22/20230821.1/images/linux/Ubuntu2204-Readme.md
2023-09-06T20:54:17.8477311Z Image Release: https://github.com/actions/runner-images/releases/tag/ubuntu22%2F20230821.1
2023-09-06T20:54:17.8477802Z ##[endgroup]
2023-09-06T20:54:17.8478168Z ##[group]Runner Image Provisioner
2023-09-06T20:54:17.8478513Z 2.0.266.1
2023-09-06T20:54:17.8478820Z ##[endgroup]
2023-09-06T20:54:17.8480162Z ##[group]GITHUB_TOKEN Permissions
2023-09-06T20:54:17.8480834Z Actions: write
2023-09-06T20:54:17.8481218Z Checks: write
2023-09-06T20:54:17.8481797Z Contents: write
2023-09-06T20:54:17.8482190Z Deployments: write
2023-09-06T20:54:17.8482577Z Discussions: write
2023-09-06T20:54:17.8482935Z Issues: write
2023-09-06T20:54:17.8483217Z Metadata: read
2023-09-06T20:54:17.8483553Z Packages: write
2023-09-06T20:54:17.8483914Z Pages: write
2023-09-06T20:54:17.8484212Z PullRequests: write
2023-09-06T20:54:17.8484605Z RepositoryProjects: write
2023-09-06T20:54:17.8484990Z SecurityEvents: write
2023-09-06T20:54:17.8485340Z Statuses: write
2023-09-06T20:54:17.8485656Z ##[endgroup]
2023-09-06T20:54:17.8489434Z Secret source: Actions
2023-09-06T20:54:17.8489965Z Prepare workflow directory
2023-09-06T20:54:17.9244286Z Prepare all required actions
2023-09-06T20:54:17.9441016Z Getting action download info
2023-09-06T20:54:18.1502062Z Download action repository 'actions/checkout@v4' (SHA:3df4ab11eba7bda6032a0b82a6bb43b11571feac)
2023-09-06T20:54:18.6047878Z Complete job name: release
2023-09-06T20:54:18.7039155Z ##[group]Run actions/checkout@v4
2023-09-06T20:54:18.7039717Z with:
2023-09-06T20:54:18.7040031Z   fetch-depth: 250
2023-09-06T20:54:18.7040298Z   fetch-tags: true
2023-09-06T20:54:18.7040608Z   repository: Molkree/github_actions
2023-09-06T20:54:18.7041197Z   token: ***
2023-09-06T20:54:18.7041482Z   ssh-strict: true
2023-09-06T20:54:18.7041770Z   persist-credentials: true
2023-09-06T20:54:18.7042069Z   clean: true
2023-09-06T20:54:18.7042378Z   sparse-checkout-cone-mode: true
2023-09-06T20:54:18.7042696Z   show-progress: true
2023-09-06T20:54:18.7042970Z   lfs: false
2023-09-06T20:54:18.7043230Z   submodules: false
2023-09-06T20:54:18.7043513Z   set-safe-directory: true
2023-09-06T20:54:18.7043798Z ##[endgroup]
2023-09-06T20:54:19.0017138Z Syncing repository: Molkree/github_actions
2023-09-06T20:54:19.0076797Z ##[group]Getting Git version info
2023-09-06T20:54:19.0077771Z Working directory is '/home/runner/work/github_actions/github_actions'
2023-09-06T20:54:19.0079224Z [command]/usr/bin/git version
2023-09-06T20:54:19.0091807Z git version 2.41.0
2023-09-06T20:54:19.0121375Z ##[endgroup]
2023-09-06T20:54:19.0207526Z Temporarily overriding HOME='/home/runner/work/_temp/2678c0f7-1146-4df1-ba64-9dafbaaf9b22' before making global git config changes
2023-09-06T20:54:19.0208204Z Adding repository directory to the temporary git global config as a safe directory
2023-09-06T20:54:19.0208921Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/github_actions/github_actions
2023-09-06T20:54:19.0265359Z Deleting the contents of '/home/runner/work/github_actions/github_actions'
2023-09-06T20:54:19.0266187Z ##[group]Initializing the repository
2023-09-06T20:54:19.0266618Z [command]/usr/bin/git init /home/runner/work/github_actions/github_actions
2023-09-06T20:54:19.0330716Z hint: Using 'master' as the name for the initial branch. This default branch name
2023-09-06T20:54:19.0334071Z hint: is subject to change. To configure the initial branch name to use in all
2023-09-06T20:54:19.0337832Z hint: of your new repositories, which will suppress this warning, call:
2023-09-06T20:54:19.0341189Z hint: 
2023-09-06T20:54:19.0344118Z hint: 	git config --global init.defaultBranch <name>
2023-09-06T20:54:19.0346914Z hint: 
2023-09-06T20:54:19.0349701Z hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
2023-09-06T20:54:19.0352666Z hint: 'development'. The just-created branch can be renamed via this command:
2023-09-06T20:54:19.0355422Z hint: 
2023-09-06T20:54:19.0358966Z hint: 	git branch -m <name>
2023-09-06T20:54:19.0434933Z Initialized empty Git repository in /home/runner/work/github_actions/github_actions/.git/
2023-09-06T20:54:19.0436097Z [command]/usr/bin/git remote add origin https://github.com/Molkree/github_actions
2023-09-06T20:54:19.0448271Z ##[endgroup]
2023-09-06T20:54:19.0449725Z ##[group]Disabling automatic garbage collection
2023-09-06T20:54:19.0474091Z [command]/usr/bin/git config --local gc.auto 0
2023-09-06T20:54:19.0529491Z ##[endgroup]
2023-09-06T20:54:19.0530029Z ##[group]Setting up auth
2023-09-06T20:54:19.0530602Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2023-09-06T20:54:19.0557039Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2023-09-06T20:54:19.0924414Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2023-09-06T20:54:19.0956478Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2023-09-06T20:54:19.1182729Z [command]/usr/bin/git config --local http.https://github.com/.extraheader AUTHORIZATION: basic ***
2023-09-06T20:54:19.1245799Z ##[endgroup]
2023-09-06T20:54:19.1246486Z ##[group]Fetching the repository
2023-09-06T20:54:19.1256140Z [command]/usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules --depth=250 origin +ec23d78ecbc48f9a867575b74a5416b78213d380:refs/tags/V1
2023-09-06T20:54:19.3386207Z ##[error]fatal: Cannot fetch both ec23d78ecbc48f9a867575b74a5416b78213d380 and refs/tags/V1 to refs/tags/V1
2023-09-06T20:54:19.3401260Z The process '/usr/bin/git' failed with exit code 128
2023-09-06T20:54:19.3401907Z Waiting 19 seconds before trying again
2023-09-06T20:54:38.3455042Z [command]/usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules --depth=250 origin +ec23d78ecbc48f9a867575b74a5416b78213d380:refs/tags/V1
2023-09-06T20:54:38.4980618Z ##[error]fatal: Cannot fetch both ec23d78ecbc48f9a867575b74a5416b78213d380 and refs/tags/V1 to refs/tags/V1
2023-09-06T20:54:38.5018376Z The process '/usr/bin/git' failed with exit code 128
2023-09-06T20:54:38.5019247Z Waiting 16 seconds before trying again
2023-09-06T20:54:54.5093632Z [command]/usr/bin/git -c protocol.version=2 fetch --prune --no-recurse-submodules --depth=250 origin +ec23d78ecbc48f9a867575b74a5416b78213d380:refs/tags/V1
2023-09-06T20:54:54.6735953Z ##[error]fatal: Cannot fetch both ec23d78ecbc48f9a867575b74a5416b78213d380 and refs/tags/V1 to refs/tags/V1
2023-09-06T20:54:54.6833580Z ##[error]The process '/usr/bin/git' failed with exit code 128
2023-09-06T20:54:54.7213201Z Post job cleanup.
2023-09-06T20:54:54.8171576Z [command]/usr/bin/git version
2023-09-06T20:54:54.8204035Z git version 2.41.0
2023-09-06T20:54:54.8270408Z Temporarily overriding HOME='/home/runner/work/_temp/355ee677-37c5-4dd2-a63a-280e77b4a35e' before making global git config changes
2023-09-06T20:54:54.8271182Z Adding repository directory to the temporary git global config as a safe directory
2023-09-06T20:54:54.8271822Z [command]/usr/bin/git config --global --add safe.directory /home/runner/work/github_actions/github_actions
2023-09-06T20:54:54.8311274Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2023-09-06T20:54:54.8359349Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :"
2023-09-06T20:54:54.8627983Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2023-09-06T20:54:54.8648042Z http.https://github.com/.extraheader
2023-09-06T20:54:54.8659258Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
2023-09-06T20:54:54.8697155Z [command]/usr/bin/git submodule foreach --recursive sh -c "git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :"
2023-09-06T20:54:54.9259704Z Cleaning up orphan processes

What am I doing wrong here?

@huxuan
Copy link

huxuan commented Sep 11, 2023

UPDATE: seems just removing the fetch-tags configuration works for me. Even with fetch-depth > 0, it will still detect the tag when the workflow is triggered by tags.


Same problem here: https://github.com/serious-scaffold/serious-scaffold-python/actions/runs/6142805118/job/16665155663

QuLogic added a commit to QuLogic/mpl-sphinx-theme that referenced this issue Sep 13, 2023
This seems to cause a conflict when the workflow is triggered by a tag
itself: actions/checkout#1467
mnot added a commit to mnot/redbot that referenced this issue Sep 16, 2023
See eg actions/checkout#1467

trying an explicit fetch-depth as per comments there.
@dfeinstein-coremap
Copy link

When I run an action on a tag, I noticed that:

- uses: actions/checkout@v4
   with:
      fetch-tags: true

Doesn't work and results in "Error: fatal: Cannot fetch both...".
When I run this however:

- uses: actions/checkout@v4
   with:
     fetch-depth: 1
     fetch-tags: true

Does work.
This seems like a bug because the default for fetch-depth is 1 so you would expect the first version to work too.

beekill95 added a commit to beekill95/torch-training-loop that referenced this issue Oct 25, 2023
Fix cannot fetch both <commit> and tags following the suggestion: actions/checkout#1467 (comment)
liskin added a commit to liskin/strava-offline that referenced this issue Nov 2, 2023
MarkusPettersson98 added a commit to mullvad/mullvadvpn-app that referenced this issue Nov 6, 2023
Due to a bug in the `actions/checkout@v4` workflow, `git fetch` fails
when the workflow was triggered by a tag: actions/checkout#1467
sodevel added a commit to wxFormBuilder/wxFormBuilder that referenced this issue Nov 13, 2023
sodevel added a commit to wxFormBuilder/wxFormBuilder that referenced this issue Nov 13, 2023
Apparently i'm special and the workaround for
actions/checkout#1467 doesn't work for me.
sodevel added a commit to wxFormBuilder/wxFormBuilder that referenced this issue Nov 13, 2023
Apparently i'm special and the workaround for
actions/checkout#1467 doesn't work for me.
@sodevel
Copy link

sodevel commented Nov 14, 2023

For some reason the fetch-depth: 1 workaround does not work for me. After some painful try-and-error i reverted back to a manual tag fetching approach.

Looking at my build logs, it seems like the commit the tag is pointing to is fetched by its hash but stored under the ref of the tag. Since git sees that a tag is attached to this commit, it tries to fetch this as well and store it under the same ref. That is causing the conflict git complains about.

Right now, when i fetch the tags manually after checkout, i have to specify --force to overwrite the existing ref. This doesn't seem to break anything, git describe finds the tag and the working copy is intact.

dennisklein added a commit to GSI-HPC/py-ina238 that referenced this issue Nov 21, 2023
brlin-tw added a commit to the-common/project-template that referenced this issue Nov 26, 2023
Currently, the checkout GitHub Action failed to check out when both
`fetch-depth` and `fetch-tags` are specified during a tag push
event(actions/checkout#1467).  This patch workarounds the issue by
manually do the tag fetch afterwards.

Refer-to: Can't fetch with `fetch-tags` when triggered by tag · Issue #1467 · actions/checkout <actions/checkout#1467>
Refer-to: Switch back to an improved manual tag fetching method · wxFormBuilder/wxFormBuilder@459563b <wxFormBuilder/wxFormBuilder@459563be8>
Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to the-common/project-template that referenced this issue Nov 26, 2023
Currently, the checkout GitHub Action failed to check out when both
`fetch-depth` and `fetch-tags` are specified during a tag push
event(actions/checkout#1467).  This patch workarounds the issue by
manually do the tag fetch afterwards.

Refer-to: Can't fetch with `fetch-tags` when triggered by tag · Issue #1467 · actions/checkout <actions/checkout#1467>
Refer-to: Switch back to an improved manual tag fetching method · wxFormBuilder/wxFormBuilder@459563b <wxFormBuilder/wxFormBuilder@459563be8>
Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
brlin-tw added a commit to the-common/project-template that referenced this issue Nov 27, 2023
Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
zerok added a commit to grafana/flagger-k6-webhook that referenced this issue Dec 11, 2023
zerok added a commit to grafana/flagger-k6-webhook that referenced this issue Dec 11, 2023
dopplershift added a commit to Unidata/MetPy that referenced this issue Dec 28, 2023
Can't use fetch-tags on a tag apparently. See actions/checkout#1467.
tt-rkim added a commit to tenstorrent/tt-metal that referenced this issue Jan 25, 2024
tt-rkim added a commit to tenstorrent/tt-metal that referenced this issue Jan 25, 2024
tt-rkim added a commit to tenstorrent/tt-metal that referenced this issue Jan 25, 2024
MarekPikula added a commit to KasiaFoszcz/AmorphousMetals that referenced this issue Feb 17, 2024
It seems that `fetch-tags` is buggy when triggering action on tag: actions/checkout#1467

Signed-off-by: Marek Pikuła <marek@serenitycode.dev>
MarekPikula added a commit to KasiaFoszcz/AmorphousMetals that referenced this issue Feb 17, 2024
It seems that `fetch-tags` is buggy when triggering action on tag: actions/checkout#1467

Signed-off-by: Marek Pikuła <marek@serenitycode.dev>
VojtechVitek added a commit to webrpc/webrpc that referenced this issue Mar 13, 2024
fatal: Cannot fetch both 8c823bf and refs/tags/v0.15.3 to refs/tags/v0.15.3

actions/checkout#1467
brianhelba added a commit to kitware-resonant/django-s3-file-field that referenced this issue Mar 22, 2024
@aghand0ur
Copy link

any update on this issue?

@ulidtko
Copy link

ulidtko commented Apr 15, 2024

also hit this on actions/cache@v3, with: { fetch-depth: 1, fetch-tags: true }.

any update?

@oshina-gravity
Copy link

oshina-gravity commented Apr 18, 2024

did anyone find a work-around that works with actions/checkout@v4?

also running into this with actions/checkout@v4 , with: { fetch-depth: 1, fetch-tags: true } or with: { fetch-depth: 0, fetch-tags: true } or with: { fetch-depth: 1 } or with: { fetch-depth: 0 }

@ulidtko
Copy link

ulidtko commented Apr 19, 2024

@oshina-gravity I worked around the issue by fetching my tag of interest manually from bash:

      - uses: actions/checkout@v3
        with:
          fetch-depth: 1
          #-- done manually in bash below, because https://github.com/actions/checkout/issues/1467
          #fetch-tags: true

      - name: Setup variables -- changelog from tag annotation message
        if: startsWith(github.ref, 'refs/tags/')
        run: |
          git fetch origin --deepen=1 +refs/tags/$TAG:refs/tags/$TAG
          # ...

This has also resolved another issue with actions/checkout for me, where fetch-tags would somehow not fetch tag annotation messages.

awesome-manuel added a commit to Awesome-Technologies/synapse-admin that referenced this issue Apr 22, 2024
The actions/checkout step has some bugs:
actions/checkout#1467

Change-Id: I6bd88433425657081c2033b55bf01587979983df
darkhorse0311 added a commit to darkhorse0311/WebRPC that referenced this issue Apr 27, 2024
fatal: Cannot fetch both 8c823bfe0180c56c89e9a54148c196fb1df3ba5b and refs/tags/v0.15.3 to refs/tags/v0.15.3

actions/checkout#1467
johanvdw added a commit to watem-sedem/watem-sedem that referenced this issue May 14, 2024
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

7 participants