Skip to content

Commit 098f1a8

Browse files
Merge pull request #39 from stefanzweifel/feature/commiter-options
Add Options to change Commit User Name and Email and Author
2 parents 81fa501 + a06032e commit 098f1a8

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...HEAD)
88

9+
### Added
10+
- Add `commit_user_name`, `commit_user_email` and `commit_author` input options for full customzation on how the commit is being created [#39](https://github.com/stefanzweifel/git-auto-commit-action/pull/39)
11+
912
### Removed
1013
- Remove the need of a GITHUB_TOKEN. Users now have to use `actions/checkout@v2` or higher [#36](https://github.com/stefanzweifel/git-auto-commit-action/pull/36)
1114

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# git-auto-commit-action
22

3-
This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the Commit back to GitHub.
4-
The Committer is "GitHub Actions <actions@github.com>" and the Author of the Commit is "Your GitHub Username <github_username@users.noreply.github.com>.
3+
This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the commit back to GitHub.
4+
The default committer is "GitHub Actions <actions@github.com>" and the default author of the commit is "Your GitHub Username <github_username@users.noreply.github.com>".
55

66
If no changes are detected, the Action does nothing.
77

@@ -28,8 +28,13 @@ Add the following step at the end of your job.
2828
# Optional glob pattern of files which should be added to the commit
2929
file_pattern: src/\*.js
3030

31-
# Optional repository path
31+
# Optional local file path to the repository
3232
repository: .
33+
34+
# Optional commit user and author settings
35+
commit_user_name: My GitHub Actions Bot
36+
commit_user_email: my-github-actions-bot@example.org
37+
commit_author: Author <actions@gitub.com>
3338
```
3439
3540
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!

action.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,32 @@ inputs:
77
commit_message:
88
description: Commit message
99
required: true
10+
branch:
11+
description: Git branch name, where changes should be pushed too.
12+
required: true
1013
commit_options:
1114
description: Commit options (eg. --no-verify)
1215
required: false
13-
branch:
14-
description: Branch name where changes should be pushed too
15-
required: true
1616
file_pattern:
17-
description: File pattern used for "git add"
17+
description: File pattern used for `git add`. For example `src/\*.js`
1818
required: false
1919
default: '.'
2020
repository:
21-
description: Path to git repository
21+
description: Local file path to the git repository. Defaults to the current directory (`.`)
2222
required: false
2323
default: '.'
24+
commit_user_name:
25+
description: Name used for the commit user
26+
required: false
27+
default: GitHub Actions
28+
commit_user_email:
29+
description: Email address used for the commit user
30+
required: false
31+
default: actions@github.com
32+
commit_author:
33+
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
34+
required: false
35+
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
2436

2537
runs:
2638
using: 'docker'

entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ _git_is_dirty() {
3333

3434
# Set up git user configuration
3535
_setup_git ( ) {
36-
git config --global user.email "actions@github.com"
37-
git config --global user.name "GitHub Actions"
36+
git config --global user.name "$INPUT_COMMIT_USER_NAME"
37+
git config --global user.email "$INPUT_COMMIT_USER_EMAIL"
3838
}
3939

4040
_switch_to_branch() {
@@ -51,7 +51,7 @@ _add_files() {
5151

5252
_local_commit() {
5353
echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}"
54-
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
54+
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$INPUT_COMMIT_AUTHOR" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
5555
}
5656

5757
_push_to_github() {

0 commit comments

Comments
 (0)