From ae38c94802cb0b53b3c8fd9eaad3337b359afa7a Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 16 May 2020 11:42:24 +0200 Subject: [PATCH 1/5] Add push_options to action.yml --- action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/action.yml b/action.yml index 7ec2100..254503a 100644 --- a/action.yml +++ b/action.yml @@ -39,6 +39,10 @@ inputs: description: Message used to create a new git tag with the commit. Keep this empty, if no tag should be created. required: false default: '' + push_options: + description: Push options (eg. --force) + required: false + default: '' outputs: changes_detected: From b0b5ed34dd1ea9619e9e3577becb4f5a8c5bac51 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 16 May 2020 11:42:40 +0200 Subject: [PATCH 2/5] Update entrypoint to handle push_options --- entrypoint.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index f6c522c..aeab256 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -73,21 +73,27 @@ _tag_commit() { } _push_to_github() { + + echo "INPUT_PUSH_OPTIONS: ${INPUT_PUSH_OPTIONS}"; + echo "::debug::Apply push options ${INPUT_PUSH_OPTIONS}"; + + INPUT_PUSH_OPTIONS_ARRAY=( $INPUT_PUSH_OPTIONS ); + if [ -z "$INPUT_BRANCH" ] then # Only add `--tags` option, if `$INPUT_TAGGING_MESSAGE` is set if [ -n "$INPUT_TAGGING_MESSAGE" ] then echo "::debug::git push origin --tags"; - git push origin --tags; + git push origin --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"}; else echo "::debug::git push origin"; - git push origin; + git push origin ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"}; fi else echo "::debug::Push commit to remote branch $INPUT_BRANCH"; - git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags; + git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags ${INPUT_PUSH_OPTIONS:+"${INPUT_PUSH_OPTIONS_ARRAY[@]}"}; fi } From 0280d2ccee11ac9f3b381931cfe9ac095538363b Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 16 May 2020 13:17:00 +0200 Subject: [PATCH 3/5] Add push_options to README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0efdded..5db8469 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add the following step at the end of your job, after other steps that might add # Optional branch to push to, defaults to the current branch branch: feature-123 - # Optional git params + # Optional options appended to `git-commit` commit_options: '--no-verify --signoff' # Optional glob pattern of files which should be added to the commit @@ -38,6 +38,9 @@ Add the following step at the end of your job, after other steps that might add # Optional tag message # Action will create and push a new tag to the remote repository and the defined branch tagging_message: 'v1.0.0' + + # Optional options appended to `git-push` + push_options: '--force' ``` ## Example From 9aab2f8a5c55879d73b6af18a0d677e54d92b17f Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 16 May 2020 13:22:34 +0200 Subject: [PATCH 4/5] Add example for protected branches --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 5db8469..d48b40f 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,19 @@ please update your Workflow configuration and usage of [`actions/checkout`](http Updating the `token` value with a Personal Access Token should fix your issues. +## Action does not push to protected branch + +If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) this Action will not be able to push to your repository. + +You have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to to use force pushes like so. + +```yaml + - uses: stefanzweifel/git-auto-commit-action@v4.2.0 + with: + commit_message: Apply php-cs-fixer changes + push_options: --force +``` + ### No new workflows are triggered by the commit of this action This is due to limitations set up by GitHub, [commits of this Action do not trigger new Workflow runs](#commits-of-this-action-do-not-trigger-new-workflow-runs). From 044b6b777c5fc321a6bde5c888021c09f77b8898 Mon Sep 17 00:00:00 2001 From: Stefan Zweifel Date: Sat, 16 May 2020 13:26:59 +0200 Subject: [PATCH 5/5] Fix Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d48b40f..1a16197 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ Updating the `token` value with a Personal Access Token should fix your issues. If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) this Action will not be able to push to your repository. -You have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to to use force pushes like so. +You have to enable force pushes to a protected branch (See [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like so. ```yaml - uses: stefanzweifel/git-auto-commit-action@v4.2.0