Skip to content

Commit

Permalink
add option to use --signoff with git commit (#46)
Browse files Browse the repository at this point in the history
* 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 <fgrandi30@gmail.com>
  • Loading branch information
pvogt09 and EndBug committed Jul 29, 2020
1 parent 46b61e1 commit 51fc21c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/entrypoint.sh
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion src/entrypoint.sh
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 51fc21c

Please sign in to comment.