From 51fc21c22124d95764176298b88d398f5b299d66 Mon Sep 17 00:00:00 2001 From: pvogt09 <50047961+pvogt09@users.noreply.github.com> Date: Wed, 29 Jul 2020 19:04:48 +0200 Subject: [PATCH] add option to use --signoff with git commit (#46) * adds option to use --signoff with git commit Signed-off-by: pvogt09 <50047961+pvogt09@users.noreply.github.com> * [auto] build: update compiled version * fix: remove quotes and refactor * [auto] build: update compiled version Co-authored-by: Federico Grandi --- README.md | 4 ++++ action.yml | 4 ++++ lib/entrypoint.sh | 7 ++++++- src/entrypoint.sh | 7 ++++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ac73939..122a785d 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,10 @@ Add a step like this to your workflow: # Default: false force: true + # Whether to use the --signoff option on `git commit` + # Default: false + signoff: true + # The message for the commit # Default: 'Commit from GitHub Actions' message: 'Your commit message' diff --git a/action.yml b/action.yml index 7242b96b..e275af22 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,10 @@ inputs: description: Whether to use the force option on git add, in order to bypass eventual gitignores required: false default: "false" + signoff: + description: Whether to use the signoff option on git commit + required: false + default: "false" message: description: The message for the commit required: false diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh index 1530923a..6e64e5fa 100755 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -31,6 +31,11 @@ remove() { if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi } +commit() { + if $INPUT_SIGNOFF; then signoffcmd=--signoff; else signoffcmd=; fi + git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" $signoffcmd +} + tag() { if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi } @@ -70,7 +75,7 @@ if ! git diff --cached --quiet --exit-code; then remove echo "Creating commit..." - git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" + commit echo "Tagging commit..." tag diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 1530923a..6e64e5fa 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -31,6 +31,11 @@ remove() { if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi } +commit() { + if $INPUT_SIGNOFF; then signoffcmd=--signoff; else signoffcmd=; fi + git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" $signoffcmd +} + tag() { if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi } @@ -70,7 +75,7 @@ if ! git diff --cached --quiet --exit-code; then remove echo "Creating commit..." - git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" + commit echo "Tagging commit..." tag