From b197c5ff8ca7d59ef3cefb8228cdea5ffe686c0c Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:12:20 +0100 Subject: [PATCH 01/12] Set default value for branch --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c5c0b53..f02f682 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,8 @@ inputs: required: true branch: description: Git branch name, where changes should be pushed too. - required: true + required: false + default: ${GITHUB_REF:11} commit_options: description: Commit options (eg. --no-verify) required: false From 5df30c89b8e74245c1235561526f707b4306c930 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:22:54 +0100 Subject: [PATCH 02/12] Update how commit is pushed --- entrypoint.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index c592998..2fa4a55 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 From e20b39e8edd36f0e14967f9cdd2feca9cad9e5a1 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:24:36 +0100 Subject: [PATCH 03/12] Remove branch default value --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f02f682..5102e64 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,7 @@ inputs: branch: description: Git branch name, where changes should be pushed too. required: false - default: ${GITHUB_REF:11} + default: null commit_options: description: Commit options (eg. --no-verify) required: false From 5ab45a4eef1a7dcd53b4289f8f002386c2c97c4b Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:26:30 +0100 Subject: [PATCH 04/12] WIP --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 2fa4a55..e5f0533 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -57,9 +57,9 @@ _local_commit() { _push_to_github() { if [ -z $INPUT_BRANCH ] then - git push origin - else git push --set-upstream origin "HEAD:$INPUT_BRANCH" + else + git push origin fi } From 0884c39e7e6e1b783776d298bf4759d9ad753695 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:28:18 +0100 Subject: [PATCH 05/12] WIP --- entrypoint.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index e5f0533..00674fb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,11 +55,11 @@ _local_commit() { } _push_to_github() { - if [ -z $INPUT_BRANCH ] + if [ -n "$INPUT_BRANCH" ] then - git push --set-upstream origin "HEAD:$INPUT_BRANCH" - else git push origin + else + git push --set-upstream origin "HEAD:$INPUT_BRANCH" fi } From 5a4e81ccd77f2138765b205c8e396dc566190543 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:31:46 +0100 Subject: [PATCH 06/12] WIP --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 00674fb..356b531 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -57,9 +57,9 @@ _local_commit() { _push_to_github() { if [ -n "$INPUT_BRANCH" ] then - git push origin - else git push --set-upstream origin "HEAD:$INPUT_BRANCH" + else + git push origin fi } From af7b14b2cfed28c43705a1982b6a022d01276aa1 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:32:57 +0100 Subject: [PATCH 07/12] WIP --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 356b531..5c5d385 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,7 +55,7 @@ _local_commit() { } _push_to_github() { - if [ -n "$INPUT_BRANCH" ] + if [ -z "$INPUT_BRANCH" ] then git push --set-upstream origin "HEAD:$INPUT_BRANCH" else From f0354eba45d71434798cc504655bb0fb7bf32bd3 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:36:48 +0100 Subject: [PATCH 08/12] WIP --- entrypoint.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5c5d385..930a6da 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,12 +55,14 @@ _local_commit() { } _push_to_github() { - if [ -z "$INPUT_BRANCH" ] - then - git push --set-upstream origin "HEAD:$INPUT_BRANCH" - else - git push origin - fi + git push origin + + # if [ -z "$INPUT_BRANCH" ] + # then + # git push --set-upstream origin "HEAD:$INPUT_BRANCH" + # else + # git push origin + # fi } _main From 42e5be9ebbd72ff55894b76bd923bd7b0fe6ad51 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Wed, 5 Feb 2020 21:39:14 +0100 Subject: [PATCH 09/12] WIP --- action.yml | 2 +- entrypoint.sh | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 5102e64..d239de0 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,7 @@ inputs: branch: description: Git branch name, where changes should be pushed too. required: false - default: null + default: '' commit_options: description: Commit options (eg. --no-verify) required: false diff --git a/entrypoint.sh b/entrypoint.sh index 930a6da..00674fb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,14 +55,12 @@ _local_commit() { } _push_to_github() { - git push origin - - # if [ -z "$INPUT_BRANCH" ] - # then - # git push --set-upstream origin "HEAD:$INPUT_BRANCH" - # else - # git push origin - # fi + if [ -n "$INPUT_BRANCH" ] + then + git push origin + else + git push --set-upstream origin "HEAD:$INPUT_BRANCH" + fi } _main From 13e281008a262dcb3f336ae66ed0328ec1322418 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Thu, 6 Feb 2020 17:51:55 +0100 Subject: [PATCH 10/12] Update entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 00674fb..87b28bc 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,7 +55,7 @@ _local_commit() { } _push_to_github() { - if [ -n "$INPUT_BRANCH" ] + if [ -z "$INPUT_BRANCH" ] then git push origin else From 33592697c4001dd06b1e7f6e0ed4b1daebab767a Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Thu, 6 Feb 2020 20:43:04 +0100 Subject: [PATCH 11/12] Update Changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fad98e..d83df0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) From 864c975b874d5cff2680de061168816ce72fd236 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Thu, 6 Feb 2020 20:49:03 +0100 Subject: [PATCH 12/12] Update README --- README.md | 27 +++++++++++++++++++++++++-- action.yml | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f32de1f..04332b6 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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/git-auto-commit-action@v3.0.0 + 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. diff --git a/action.yml b/action.yml index d239de0..4988a84 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: description: Commit message required: true branch: - description: Git branch name, where changes should be pushed too. + 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: