Skip to content

Commit 51fc21c

Browse files
pvogt09EndBug
andauthored
add option to use --signoff with git commit (#46)
* adds option to use --signoff with git commit Signed-off-by: pvogt09 <[email protected]> * [auto] build: update compiled version * fix: remove quotes and refactor * [auto] build: update compiled version Co-authored-by: Federico Grandi <[email protected]>
1 parent 46b61e1 commit 51fc21c

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Add a step like this to your workflow:
3535
# Default: false
3636
force: true
3737

38+
# Whether to use the --signoff option on `git commit`
39+
# Default: false
40+
signoff: true
41+
3842
# The message for the commit
3943
# Default: 'Commit from GitHub Actions'
4044
message: 'Your commit message'

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ inputs:
2020
description: Whether to use the force option on git add, in order to bypass eventual gitignores
2121
required: false
2222
default: "false"
23+
signoff:
24+
description: Whether to use the signoff option on git commit
25+
required: false
26+
default: "false"
2327
message:
2428
description: The message for the commit
2529
required: false

lib/entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ remove() {
3131
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
3232
}
3333

34+
commit() {
35+
if $INPUT_SIGNOFF; then signoffcmd=--signoff; else signoffcmd=; fi
36+
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" $signoffcmd
37+
}
38+
3439
tag() {
3540
if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi
3641
}
@@ -70,7 +75,7 @@ if ! git diff --cached --quiet --exit-code; then
7075
remove
7176

7277
echo "Creating commit..."
73-
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
78+
commit
7479

7580
echo "Tagging commit..."
7681
tag

src/entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ remove() {
3131
if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi
3232
}
3333

34+
commit() {
35+
if $INPUT_SIGNOFF; then signoffcmd=--signoff; else signoffcmd=; fi
36+
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" $signoffcmd
37+
}
38+
3439
tag() {
3540
if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi
3641
}
@@ -70,7 +75,7 @@ if ! git diff --cached --quiet --exit-code; then
7075
remove
7176

7277
echo "Creating commit..."
73-
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>"
78+
commit
7479

7580
echo "Tagging commit..."
7681
tag

0 commit comments

Comments
 (0)