From 754f529310ba17c4c99e252697545501cb9552c1 Mon Sep 17 00:00:00 2001 From: Fabian Esslinger Date: Sun, 17 Sep 2023 00:03:04 -0300 Subject: [PATCH] feat: add option to ignore git hooks on commit --- README.md | 1 + action.yml | 3 +++ start.sh | 13 +++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8aad92b..e016866 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ jobs: | force | boolean | false | Determines if force push is used. | | tags | boolean | false | Determines if `--tags` is used. | | directory | string | '.' | Directory to change to before pushing. | +| no_verify | boolean | false | Ignore git hooks on commit | | repository | string | '' | Repository name. Default or empty repository name represents current github repository. If you want to push to other repository, you should make a [personal access token](https://github.com/settings/tokens) and use it as the `github_token` input. | ## License diff --git a/action.yml b/action.yml index f985c30..d851105 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,9 @@ inputs: description: 'Directory to change to before pushing.' required: false default: '.' + no_verify: + description: 'Ignore git hooks' + required: false runs: using: 'node16' main: 'start.js' diff --git a/start.sh b/start.sh index 2cf6345..d773868 100644 --- a/start.sh +++ b/start.sh @@ -14,6 +14,7 @@ INPUT_FORCE=${INPUT_FORCE:-false} INPUT_TAGS=${INPUT_TAGS:-false} INPUT_EMPTY=${INPUT_EMPTY:-false} INPUT_DIRECTORY=${INPUT_DIRECTORY:-'.'} +INPUT_NO_VERIFY=${INPUT_NO_VERIFY:-false} REPOSITORY=${INPUT_REPOSITORY:-$GITHUB_REPOSITORY} echo "Push to branch $INPUT_BRANCH"; @@ -38,6 +39,10 @@ if ${INPUT_TAGS}; then _TAGS='--tags' fi +if ${INPUT_NO_VERIFY}; then + _NO_VERIFY='--no-verify' +fi + cd "${INPUT_DIRECTORY}" remote_repo="https://${GITHUB_ACTOR}:${INPUT_GITHUB_TOKEN}@github.com/${REPOSITORY}.git" @@ -50,20 +55,20 @@ git add -A if ${INPUT_AMEND}; then if [ -n "${INPUT_COAUTHOR_EMAIL}" ] && [ -n "${INPUT_COAUTHOR_NAME}" ]; then - git commit ${_AMEND} -m "${INPUT_MESSAGE} + git commit ${_AMEND} ${_NO_VERIFY} -m "${INPUT_MESSAGE} Co-authored-by: ${INPUT_COAUTHOR_NAME} <${INPUT_COAUTHOR_EMAIL}>" || exit 0 else - git commit ${_AMEND} -m "${INPUT_MESSAGE}" $_EMPTY || exit 0 + git commit ${_AMEND} ${_NO_VERIFY} -m "${INPUT_MESSAGE}" $_EMPTY || exit 0 fi elif [ -n "${INPUT_COAUTHOR_EMAIL}" ] && [ -n "${INPUT_COAUTHOR_NAME}" ]; then - git commit -m "${INPUT_MESSAGE} + git commit ${_NO_VERIFY} -m "${INPUT_MESSAGE} Co-authored-by: ${INPUT_COAUTHOR_NAME} <${INPUT_COAUTHOR_EMAIL}>" $_EMPTY || exit 0 else - git commit -m "${INPUT_MESSAGE}" $_EMPTY || exit 0 + git commit ${_NO_VERIFY} -m "${INPUT_MESSAGE}" $_EMPTY || exit 0 fi git push "${remote_repo}" HEAD:"${INPUT_BRANCH}" --follow-tags $_FORCE_OPTION $_TAGS; \ No newline at end of file