stefanzweifel / git-auto-commit-action

Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.
MIT License
2.02k stars 229 forks source link

Can't push branch and create tag at the same time #145

Closed evantahler closed 3 years ago

evantahler commented 3 years ago

Version of the Action v4 (@v4)

Describe the bug

Reading the docs, I would expect the following to both push any changes back to the branch AND tag that commit with env.CORE_VERSION. However, what is happening is that the tag is created but the branch is not updated.

Action will create and push a new tag to the remote repository and the defined branch

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Updating Packages
          commit_user_name: Grouparoo Bot
          commit_user_email: hello@grouparoo.com
          commit_author: Grouparoo Bot <hello@grouparoo.com>
          branch: ${{ github.head_ref }}
          tagging_message: v${{ env.CORE_VERSION }}

Action: https://github.com/grouparoo/app-example/blob/master/.github/workflows/update.yml Run: https://github.com/grouparoo/app-example/runs/1983284335?check_suite_focus=true

Specifcally:

Started: bash /home/runner/work/_actions/stefanzweifel/git-auto-commit-action/v4/entrypoint.sh
INPUT_REPOSITORY value: .
INPUT_BRANCH value: 
From https://github.com/grouparoo/app-example
 * [new branch]      helm       -> origin/helm
M   package-lock.json
M   package.json
Your branch is up to date with 'origin/master'.
INPUT_FILE_PATTERN: .
INPUT_COMMIT_OPTIONS: 
INPUT_COMMIT_USER_NAME: Grouparoo Bot
INPUT_COMMIT_USER_EMAIL: hello@grouparoo.com
INPUT_COMMIT_MESSAGE: Updating Packages
INPUT_COMMIT_AUTHOR: Grouparoo Bot <hello@grouparoo.com>
[master 1ede8b3] Updating Packages
 2 files changed, 738 insertions(+), 893 deletions(-)
INPUT_TAGGING_MESSAGE: v0.2.3
INPUT_PUSH_OPTIONS: 
To https://github.com/grouparoo/app-example
 * [new tag]         v0.2.3 -> v0.2.3

Expected behavior I would expect both the branch to be pushed with the latest code & the tag to be created.

stefanzweifel commented 3 years ago

Thanks for reporting!

As you said, the tag is created: https://github.com/grouparoo/app-example/commit/1ede8b3c7f184dd2ca751688c6a4d97d4658cdd3

I wonder if this is related to this message GitHub displays :

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files.

Maybe it's related that the workflow was triggered by workflow_dispatch đŸ¤” https://github.com/grouparoo/app-example/actions/runs/600989846

I will try to come up with a failing test for our test suite to ensure that we can reproduce this.

evantahler commented 3 years ago

Thanks!

Here's what I'm doing in the interum https://github.com/grouparoo/app-example/pull/124

stefanzweifel commented 3 years ago

@evantahler Can confirm that the pushed commits are not correct. Will push a PR with tests and a solution shortly.

Would then be great if you could test those changes in your project, to make sure it really works as expected.

stefanzweifel commented 3 years ago

@evantahler I've opened a PR with a fix in #146

You can use it by updating your workflow like this:

-       - uses: stefanzweifel/git-auto-commit-action@v4
+       - uses: stefanzweifel/git-auto-commit-action@fixes/145
         with:
           commit_message: Updating Packages
           commit_user_name: Grouparoo Bot
           commit_user_email: hello@grouparoo.com
           commit_author: Grouparoo Bot <hello@grouparoo.com>
           branch: ${{ github.head_ref }}
           tagging_message: v${{ env.CORE_VERSION }}

I will do some additional tests in my own projects. If everything goes well, I will tag a new version next week.

evantahler commented 3 years ago

Thanks for checking this out so quickly! It works!

I gave it a try:

Produced this commit https://github.com/grouparoo/app-example/commit/8f4c57de49f6370da5f080577e0bc69f0ac5e5be and the tag https://github.com/grouparoo/app-example/releases/tag/v0.2.3

stefanzweifel commented 3 years ago

v4.9.2 has been released which includes the mentioned fix.

I will close this issue now. Feel free to reopen or open a new issue if you have a problem.

Thanks again for reporting!

evantahler commented 3 years ago

Thank you!

evantahler commented 3 years ago

Huh... https://github.com/grouparoo/app-example/actions/runs/622211253

Unable to resolve action stefanzweifel/git-auto-commit-action@4.9.2, unable to find version 4.9.2

stefanzweifel commented 3 years ago

@evantahler Can you try it with stefanzweifel/git-auto-commit-action@v4.9.2 or just v4?

evantahler commented 3 years ago

OH! I forgot the v. Thanks again!