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 · 11 comments
Open

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

Molkree opened this issue Sep 6, 2023 · 11 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.
yejunjin added a commit to modelscope/dash-infer that referenced this issue Jun 30, 2024
Here is bug of actions/checkout: actions/checkout#1467
yejunjin added a commit to modelscope/dash-infer that referenced this issue Jun 30, 2024
Here is bug of actions/checkout: actions/checkout#1467
tigarmo added a commit to canonical/craft-application that referenced this issue Jul 4, 2024
This is a partial revert of 0115c28; apparently actions/checkout's
"fetch-tags" property is broken and gives errors at checkout time.

Ref: actions/checkout#1467
tigarmo added a commit to canonical/craft-application that referenced this issue Jul 4, 2024
This is a partial revert of 0115c28; apparently actions/checkout's
"fetch-tags" property is broken and gives errors at checkout time.

Ref: actions/checkout#1467
gsanchietti added a commit to NethServer/nethsecurity that referenced this issue Jul 30, 2024
gsanchietti added a commit to NethServer/nethsecurity that referenced this issue Jul 30, 2024
Fetch git tags manually.

Ref actions/checkout#1467
twomagpi pushed a commit to ukhsa-collaboration/pygom that referenced this issue Aug 6, 2024
mem added a commit to grafana/grafana-build-tools that referenced this issue Aug 10, 2024
It sounds like fetch tags is not needed?

actions/checkout#1467

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
mem added a commit to grafana/grafana-build-tools that referenced this issue Aug 10, 2024
It sounds like fetch tags is not needed?

actions/checkout#1467

Signed-off-by: Marcelo E. Magallon <marcelo.magallon@grafana.com>
yashanand1910 added a commit to cedana/cedana that referenced this issue Aug 14, 2024
joanise added a commit to roedoejet/g2p that referenced this issue Aug 22, 2024
@john-funk
Copy link

Looking at https://github.com/actions/checkout/blob/eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871/dist/index.js#L657 it seems to me, that all fetch-tags: 1 does, is prevent setting --no-tags, so that only tags that point into the histories being fetched are also fetched.

Molkree added a commit to ATTWoWAddon/AllTheThings that referenced this issue Nov 10, 2024
Can't do that through actions/checkout due to actions/checkout#1467
NORPG pushed a commit to ATTWoWAddon/AllTheThings that referenced this issue Nov 13, 2024
Can't do that through actions/checkout due to actions/checkout#1467
NORPG pushed a commit to ATTWoWAddon/AllTheThings that referenced this issue Nov 14, 2024
Can't do that through actions/checkout due to actions/checkout#1467
salcc added a commit to AI-sandbox/snputils that referenced this issue Nov 16, 2024
mgautierfr added a commit to jubako/jubako that referenced this issue Nov 22, 2024
dcrossleyau added a commit to folio-org/.github that referenced this issue Nov 27, 2024
The fetch-tags during checkout is not effective.
actions/checkout#1467 (comment)
xen0n added a commit to ruyisdk/ruyi that referenced this issue Dec 1, 2024
amercader added a commit to ckan/ckan-docker-base that referenced this issue Dec 3, 2024
`fetch-tags: true` in the checkout action does not work as expected and
causes an error:

    Error: fatal: Cannot fetch both 2704e6e
    and refs/tags/v20241203 to refs/tags/v20241203

The issue is described in
actions/checkout#1467

We will just fetch the tags manually
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

10 participants