Skip to content

Commit 1d39bb6

Browse files
Merge pull request #41 from stefanzweifel/feature/make-branch-optional
Make branch option optional
2 parents 098f1a8 + 864c975 commit 1d39bb6

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
### Added
1010
- 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)
1111

12+
### Changed
13+
- Make the `branch` input option optional [#41](https://github.com/stefanzweifel/git-auto-commit-action/pull/41)
14+
1215
### Removed
1316
- 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)
1417

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ This Action has been inspired and adapted from the [auto-commit](https://github.
1717
Add the following step at the end of your job.
1818

1919
```yaml
20-
- uses: stefanzweifel/git-auto-commit-action@v2.5.0
20+
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
2121
with:
2222
commit_message: Apply automatic changes
23+
24+
# Optional name of the branch the commit should be pushed to
25+
# Required if Action is used in Workflow listening to the `pull_request` event
2326
branch: ${{ github.head_ref }}
2427

2528
# Optional git params
@@ -65,12 +68,32 @@ jobs:
6568
- name: Run php-cs-fixer
6669
uses: docker://oskarstark/php-cs-fixer-ga
6770
68-
- uses: stefanzweifel/git-auto-commit-action@v2.5.0
71+
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
6972
with:
7073
commit_message: Apply php-cs-fixer changes
7174
branch: ${{ github.head_ref }}
7275
```
7376

77+
```yaml
78+
name: php-cs-fixer
79+
80+
on: push
81+
82+
jobs:
83+
php-cs-fixer:
84+
runs-on: ubuntu-latest
85+
86+
steps:
87+
- uses: actions/checkout@v2
88+
89+
- name: Run php-cs-fixer
90+
uses: docker://oskarstark/php-cs-fixer-ga
91+
92+
- uses: stefanzweifel/git-auto-commit-action@v3.0.0
93+
with:
94+
commit_message: Apply php-cs-fixer changes
95+
```
96+
7497
### Inputs
7598

7699
Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.

action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ inputs:
88
description: Commit message
99
required: true
1010
branch:
11-
description: Git branch name, where changes should be pushed too.
12-
required: true
11+
description: Git branch name, where changes should be pushed too. Required if Action is used on the `pull_request` event
12+
required: false
13+
default: ''
1314
commit_options:
1415
description: Commit options (eg. --no-verify)
1516
required: false

entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ _local_commit() {
5555
}
5656

5757
_push_to_github() {
58-
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
58+
if [ -z "$INPUT_BRANCH" ]
59+
then
60+
git push origin
61+
else
62+
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
63+
fi
5964
}
6065

6166
_main

0 commit comments

Comments
 (0)