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
1.97k stars 226 forks source link

Cannot use this action in Reusable Workflow #216

Closed edmondop closed 2 years ago

edmondop commented 2 years ago

This action is relying on some context / environment variable from the GitHub pipeline, so it is not suitable to be run in a pipeline which workflow triggers is workflow_call

fatal: could not read Username for 'https://github.com/': No such device or address

stefanzweifel commented 2 years ago

The Action relies on actions/checkout for setting up git authentication. actions/checkout must be used/called before git-auto-commit to make this Action work.

It's not directly listed as a requirement, as I assumed everyone using the Actions uses actions/checkout somewhere in their workflow. (The README only mentions that at least v2 has to be used)

Here is a reusable workflow that triggers with workflow_call and uses git-auto-commit-action: https://github.com/laravel/.github/blob/main/.github/workflows/update-changelog.yml

Hope this resolves this issues for you. If not, feel free to reopen and share the workflow file that gives you trouble.

edmondop commented 2 years ago

You are right, it was the v2 thing. My fault :(

Now it works! Although, the commit invalidate all the checks on the PR :(

stefanzweifel commented 2 years ago

Although, the commit invalidate all the checks on the PR :(

Yeah, that a limitation by GitHub. Instead of using the default GITHUB_TOKEN you could issue your own personal acces token and use that token to make the commit. More information on this here: https://github.com/stefanzweifel/git-auto-commit-action#commits-made-by-this-action-do-not-trigger-new-workflow-runs

Commits made by git-auto-commit would then retrigger all your checks again. Just beware that you don't create an infinite recursion ;)