diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a1ea45..1fad98e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...HEAD) +### Added +- 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) + ### Removed - 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) diff --git a/README.md b/README.md index 6d88705..f32de1f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # git-auto-commit-action -This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the Commit back to GitHub. -The Committer is "GitHub Actions " and the Author of the Commit is "Your GitHub Username . +This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the commit back to GitHub. +The default committer is "GitHub Actions " and the default author of the commit is "Your GitHub Username ". If no changes are detected, the Action does nothing. @@ -28,8 +28,13 @@ Add the following step at the end of your job. # Optional glob pattern of files which should be added to the commit file_pattern: src/\*.js - # Optional repository path + # Optional local file path to the repository repository: . + + # Optional commit user and author settings + commit_user_name: My GitHub Actions Bot + commit_user_email: my-github-actions-bot@example.org + commit_author: Author ``` The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run! diff --git a/action.yml b/action.yml index 2fb26e7..c5c0b53 100644 --- a/action.yml +++ b/action.yml @@ -7,20 +7,32 @@ inputs: commit_message: description: Commit message required: true + branch: + description: Git branch name, where changes should be pushed too. + required: true commit_options: description: Commit options (eg. --no-verify) required: false - branch: - description: Branch name where changes should be pushed too - required: true file_pattern: - description: File pattern used for "git add" + description: File pattern used for `git add`. For example `src/\*.js` required: false default: '.' repository: - description: Path to git repository + description: Local file path to the git repository. Defaults to the current directory (`.`) required: false default: '.' + commit_user_name: + description: Name used for the commit user + required: false + default: GitHub Actions + commit_user_email: + description: Email address used for the commit user + required: false + default: actions@github.com + commit_author: + description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run. + required: false + default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> runs: using: 'docker' diff --git a/entrypoint.sh b/entrypoint.sh index eb1b743..c592998 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -33,8 +33,8 @@ _git_is_dirty() { # Set up git user configuration _setup_git ( ) { - git config --global user.email "actions@github.com" - git config --global user.name "GitHub Actions" + git config --global user.name "$INPUT_COMMIT_USER_NAME" + git config --global user.email "$INPUT_COMMIT_USER_EMAIL" } _switch_to_branch() { @@ -51,7 +51,7 @@ _add_files() { _local_commit() { echo "INPUT_COMMIT_OPTIONS: ${INPUT_COMMIT_OPTIONS}" - git commit -m "$INPUT_COMMIT_MESSAGE" --author="$GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"} + git commit -m "$INPUT_COMMIT_MESSAGE" --author="$INPUT_COMMIT_AUTHOR" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"} } _push_to_github() {