Skip to content

Commit 156f2b1

Browse files
authored
feat: add support for amend input (#12)
1 parent 9624971 commit 156f2b1

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
| message | string | 'chore: autopublish ${date}' | Commit message. |
4545
| branch | string | 'main' | Destination branch to push changes. |
4646
| empty | boolean | false | Allow empty commit. |
47+
| amend | boolean | false | Determines if the commit should be amended. Needs to be used with `force` input to force push the amended commit. |
4748
| force | boolean | false | Determines if force push is used. |
4849
| tags | boolean | false | Determines if `--tags` is used. |
4950
| directory | string | '.' | Directory to change to before pushing. |

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ inputs:
3333
empty:
3434
description: 'Allow empty commit'
3535
required: false
36+
amend:
37+
description: 'Determines if the commit should be amended'
38+
required: false
39+
default: 'false'
3640
force:
3741
description: 'Determines if force push is used'
3842
required: false

start.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ INPUT_COAUTHOR_EMAIL=${INPUT_COAUTHOR_EMAIL:-''}
99
INPUT_COAUTHOR_NAME=${INPUT_COAUTHOR_NAME:-''}
1010
INPUT_MESSAGE=${INPUT_MESSAGE:-"chore: autopublish ${timestamp}"}
1111
INPUT_BRANCH=${INPUT_BRANCH:-master}
12+
INPUT_AMEND=${INPUT_AMEND:-false}
1213
INPUT_FORCE=${INPUT_FORCE:-false}
1314
INPUT_TAGS=${INPUT_TAGS:-false}
1415
INPUT_EMPTY=${INPUT_EMPTY:-false}
@@ -25,6 +26,10 @@ if ${INPUT_EMPTY}; then
2526
_EMPTY='--allow-empty'
2627
fi
2728

29+
if ${INPUT_AMEND}; then
30+
_AMEND='--amend --no-edit'
31+
fi
32+
2833
if ${INPUT_FORCE}; then
2934
_FORCE_OPTION='--force'
3035
fi
@@ -43,7 +48,16 @@ git config --local user.name "${INPUT_AUTHOR_NAME}"
4348

4449
git add -A
4550

46-
if [ -n "${INPUT_COAUTHOR_EMAIL}" ] && [ -n "${INPUT_COAUTHOR_NAME}" ]; then
51+
if ${INPUT_AMEND}; then
52+
if [ -n "${INPUT_COAUTHOR_EMAIL}" ] && [ -n "${INPUT_COAUTHOR_NAME}" ]; then
53+
git commit ${_AMEND} -m "${INPUT_MESSAGE}
54+
55+
Co-authored-by: ${INPUT_COAUTHOR_NAME} <${INPUT_COAUTHOR_EMAIL}>" || exit 0
56+
else
57+
git commit ${_AMEND} -m "${INPUT_MESSAGE}" $_EMPTY || exit 0
58+
fi
59+
60+
elif [ -n "${INPUT_COAUTHOR_EMAIL}" ] && [ -n "${INPUT_COAUTHOR_NAME}" ]; then
4761
git commit -m "${INPUT_MESSAGE}
4862
4963

0 commit comments

Comments
 (0)