Skip to content

Commit 12f6863

Browse files
Clarify commit_author input option (#315)
* Clarify `commit_author` input option * Update README.md --------- Co-authored-by: Stefan Zweifel <stefanzweifel@users.noreply.github.com>
1 parent 29183a2 commit 12f6863

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The following is an extended example with all available options.
8282
# Optional commit user and author settings
8383
commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]"
8484
commit_user_email: my-github-actions-bot@example.org # defaults to "41898282+github-actions[bot]@users.noreply.github.com"
85-
commit_author: Author <actions@github.com> # defaults to author of the commit that triggered the run
85+
commit_author: Author <actions@github.com> # defaults to "username <username@users.noreply.github.com>", where "username" belongs to the author of the commit that triggered the run
8686

8787
# Optional. Tag name being created in the local repository and
8888
# pushed to remote repository and defined branch.
@@ -353,6 +353,8 @@ If you would like to use this Action to create a commit using [`--amend`](https:
353353
First, you need to extract the previous commit message by using `git log -1 --pretty=%s`.
354354
Then you need to provide this last commit message to the Action through the `commit_message` input option.
355355

356+
By default, the commit author is changed to `username <username@users.noreply.github.com>`, where `username` is the name of the user who triggered the workflow (The [`github.actor`](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) context is used here). If you want to preserve the name and email of the original author, you must extract them from the last commit and provide them to the Action through the `commit_author` input option.
357+
356358
Finally, you have to use `push_options: '--force'` to overwrite the git history on the GitHub remote repository. (git-auto-commit will not do a `git-rebase` for you!)
357359

358360
The steps in your workflow might look like this:
@@ -366,13 +368,15 @@ The steps in your workflow might look like this:
366368
# Other steps in your workflow to trigger a changed file
367369
368370
- name: Get last commit message
369-
id: last-commit-message
371+
id: last-commit
370372
run: |
371-
echo "msg=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
373+
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
374+
echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT
372375
373376
- uses: stefanzweifel/git-auto-commit-action@v5
374377
with:
375-
commit_message: ${{ steps.last-commit-message.outputs.msg }}
378+
commit_author: ${{ steps.last-commit.outputs.author }}
379+
commit_message: ${{ steps.last-commit.outputs.message }}
376380
commit_options: '--amend --no-edit'
377381
push_options: '--force'
378382
skip_fetch: true

0 commit comments

Comments
 (0)