Skip to content

Issue when running within tag push runners. #131

Closed

Description

@michealroberts

I have the following at the top of my workflow file:

name: useaestrium/tag

on:
  push:
    tags:        
        - '*.*.*'
        - '[0-9]+.[0-9]+.[0-9]+'
        - '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

And the running is triggered for a tagged runner.

However, I am seeing the following issue when attempting to push:

fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

    git push origin HEAD:<name-of-remote-branch>

I'm using the action as follows:

      # Push the updated package.json file to the repository
      - name: Push package.json version
        if: steps.check-tag.outputs.match == 'true'
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          force_with_lease: true

Is there anything I am doing wrong here, or any way to fix the issue I am seeing?

Activity

  1. ZPascal commented on Jun 26, 2022

    @ZPascal
    Collaborator

    Hi @michealroberts, I'm the person who implemented the force_with_lease functionality. Could you please check and post the checkout section?

    It's necessary that you set the following parameters.

    - uses: actions/checkout@v3
      with:
        ref: ${{ github.head_ref }}
        fetch-depth: 0
  2. self-assigned this
    on Jun 26, 2022
  3. michealroberts commented on Jun 26, 2022

    @michealroberts
    Author

    Hi Pascal,

    Thank you for your swift response, especially on a Sunday! Thank you.

    Hmmm, ok I have that set as you explained and as outlined in the README.md. I wonder if it's because we aren't pushing to origin?

    I think it could be because the action is triggered on tag push, and not a branch push?

  4. ZPascal commented on Jun 26, 2022

    @ZPascal
    Collaborator

    Hi Michael, that could be the problem. Do you have a public available Action file that I could copy and paste in my test scenario and checking the case?

  5. changed the title [-]Issue when running within on tag push runners.[/-] [+]Issue when running within tag push runners.[/+] on Jun 27, 2022
  6. michealroberts commented on Jun 27, 2022

    @michealroberts
    Author

    I don't I'm afraid - I think the key lies in testing your action within a tagged runner, e.g., something like this:

    on:
      push:
        tags:        
            - '*.*.*'
            - '[0-9]+.[0-9]+.[0-9]+'
            - '[0-9]+.[0-9]+.[0-9]+rc[0-9]+'
    
      # Allows you to run this workflow manually from the Actions tab
      workflow_dispatch:

    Let me know if you need anything else ...

  7. ZPascal commented on Jun 27, 2022

    @ZPascal
    Collaborator

    Hi @michealroberts, I've reproduced the issue on my side. I've understood that the job is triggered by a tag. Could you please describe what you want to do exactly and the case? Do you want to push tags or to a branch?

  8. michealroberts commented on Jun 27, 2022

    @michealroberts
    Author

    Hi @michealroberts, I've reproduced the issue on my side. I've understood that the job is triggered by a tag. Could you please describe what you want to do exactly and the case? Do you want to push tags or to a branch?

    @ZPascal Hi Pascal. That's great. So when we release, we automatically tag and that then bumps of package.json version to the same tag as the tagged release, and pushes back to the repo. This then triggers a further workflow that essentially runs on any push to main but completes if the version has been bumped in the package.json, at which point it publishes the release.

    Hopefully that makes sense!

  9. ZPascal commented on Jun 27, 2022

    @ZPascal
    Collaborator

    Hi @michealroberts, only for better understanding, you push the same tag in the same or in a different repository back?

    Update: I think, I've identified the root cause of the issue, and I'm currently working on a solution.

  10. ZPascal commented on Jun 30, 2022

    @ZPascal
    Collaborator

    Hi @michealroberts,

    I did some tests with --force-with-lease parameter in my test scenario and found that from my point of view, it is not possible to use --force-with-lease parameter to overwrite a tag. I did a test here with the --force parameter and was able to successfully overwrite the checked out tag. For this, I also updated the upstream branch at the same time. Is there any obstacle from your side?

    BTW: Here is the draft PR, which also adjusts the documentation and the push process at the same time.

  11. michealroberts commented on Jun 30, 2022

    @michealroberts
    Author

    Hi Pascal, there may be some confusion. Basically, when the tag changes, I want to be able to push back to the repo. The way I have achieved this outside of this action is the following:

    # Push the updated package.json file to the repository
          - name: Push package.json version
            if: steps.check-tag.outputs.match == 'true'
            run: |
              git push origin HEAD:main
    
  12. ZPascal commented on Oct 17, 2022

    @ZPascal
    Collaborator

    Hi @michealroberts, so you don't want to update the tagged version and only push pack to the corresponding branch and this is not possible? Is it possible to share the anonymized GitHub Action file to reproduce your case on my test setup?

  13. removed their assignment
    on Feb 2, 2023
  14. ZPascal commented on May 23, 2026

    @ZPascal
    Collaborator

    Hi @michealroberts,

    After investigating this further, what you're seeing is a workflow design issue rather than a bug in the action. When a tag push triggers a workflow, GitHub checks out the tagged commit directly — no branch, just a detached HEAD. That's why git refuses to push: it simply doesn't know where to push to.

    The cleaner approach for what you're trying to do would be to bump package.json before tagging:

    1. Bump the version and push to main
    2. Tag that commit
    3. Done — the tag already points to the correct version

    Bumping after the tag means the tag itself points to the old version, with the fix sneaking in through a later commit. That defeats the purpose of the tag.

    If you still need to push back to a branch from a tag-triggered workflow, you can work around it by explicitly setting branch: main in the action config — that way it pushes HEAD:main/ master and git knows the target. I've also added a warning to the action output that flags detached HEAD situations and points to this recommendation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions