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

feat: add option to ignore git hooks on commit #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
13 changes: 9 additions & 4 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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"
Expand All @@ -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;