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

Ref to tag should be sha of workflow, not commit_sha #47

Open
bakoontz2 opened this issue Mar 8, 2024 · 0 comments
Open

Ref to tag should be sha of workflow, not commit_sha #47

bakoontz2 opened this issue Mar 8, 2024 · 0 comments

Comments

@bakoontz2
Copy link

Describe the bug
If a workflow is triggered from one branch, and then actions/checkout is invoked to check out a different branch, action-create-tag attempts to tag the wrong commit, generating a "fatal: bad object type" error.

To Reproduce
Steps to reproduce the behavior:

  1. Create an action that does a checkout from a branch different from the commit that triggered the workflow.
  2. In the yaml, call actions/checkout followed by action-create-tag.
  3. An error will result due to a mismatch between the expected commit of the workflow and commit_sha, which still reflects the triggering workflow commit.

Expected behavior
It's not clear to my why the GH folks think it's a good idea to leave commit_sha set to the triggering workflow. But when a checkout on a different branch is done, commit_sha is no longer accurate, and action_create_tag should be using as the default the commit sha of the checkout.

Workaround
The only workaround I've found is to add an extra step to get the workspace commit, and override the action default:

    - uses: actions/checkout@v4
      with:
        progress: false
        ref: ${{ inputs.build-branch }}

    - name: Get workspace sha
      run: |
        echo "WORKSPACE_SHA=$(/usr/bin/git log -1 --format='%H')" >> $GITHUB_ENV

    - name: Tag the commit with the version
      uses: rickstaa/action-create-tag@v1
      with:
        tag: ${{env.TAG}}
        commit_sha: ${{ env.WORKSPACE_SHA }}
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

1 participant