Skip to content

Commit

Permalink
Merge pull request #39 from stefanzweifel/feature/commiter-options
Browse files Browse the repository at this point in the history
Add Options to change Commit User Name and Email and Author
  • Loading branch information
stefanzweifel authored Feb 5, 2020
2 parents 81fa501 + a06032e commit 098f1a8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <actions@github.com>" and the Author of the Commit is "Your GitHub Username <github_username@users.noreply.github.com>.
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 <actions@github.com>" and the default author of the commit is "Your GitHub Username <github_username@users.noreply.github.com>".

If no changes are detected, the Action does nothing.

Expand All @@ -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 <actions@gitub.com>
```
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
Expand Down
22 changes: 17 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down

0 comments on commit 098f1a8

Please sign in to comment.