Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make branch option optional #41

Merged
merged 12 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### 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)

### Changed
- Make the `branch` input option optional [#41](https://github.com/stefanzweifel/git-auto-commit-action/pull/41)

### 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
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ This Action has been inspired and adapted from the [auto-commit](https://github.
Add the following step at the end of your job.

```yaml
- uses: stefanzweifel/git-auto-commit-action@v2.5.0
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
with:
commit_message: Apply automatic changes

# Optional name of the branch the commit should be pushed to
# Required if Action is used in Workflow listening to the `pull_request` event
branch: ${{ github.head_ref }}

# Optional git params
Expand Down Expand Up @@ -65,12 +68,32 @@ jobs:
- name: Run php-cs-fixer
uses: docker://oskarstark/php-cs-fixer-ga

- uses: stefanzweifel/git-auto-commit-action@v2.5.0
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
with:
commit_message: Apply php-cs-fixer changes
branch: ${{ github.head_ref }}
```

```yaml
name: php-cs-fixer

on: push

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run php-cs-fixer
uses: docker://oskarstark/php-cs-fixer-ga

- uses: stefanzweifel/[email protected]
with:
commit_message: Apply php-cs-fixer changes
```

### Inputs

Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.
Expand Down
5 changes: 3 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ inputs:
description: Commit message
required: true
branch:
description: Git branch name, where changes should be pushed too.
required: true
description: Git branch name, where changes should be pushed too. Required if Action is used on the `pull_request` event
required: false
default: ''
commit_options:
description: Commit options (eg. --no-verify)
required: false
Expand Down
7 changes: 6 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ _local_commit() {
}

_push_to_github() {
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
if [ -z "$INPUT_BRANCH" ]
then
git push origin
else
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
fi
}

_main