File tree Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change
1
+ .idea
2
+ * .iml
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ LABEL "repository"="https://github.com/EndBug/add-and-commit"
9
9
LABEL "homepage" ="https://github.com/EndBug/add-and-commit"
10
10
LABEL "maintainer" =
"Federico Grandi <[email protected] >"
11
11
12
+ RUN apk add jq
13
+
12
14
COPY entrypoint.sh /entrypoint.sh
13
15
14
16
ENTRYPOINT ["sh" , "/entrypoint.sh" ]
Original file line number Diff line number Diff line change @@ -3,13 +3,11 @@ description: 'Add & commit files from a path directly from GitHub Actions'
3
3
4
4
inputs :
5
5
author_name :
6
- description : ' The name of the user that will be displayed as the author of the commit'
7
- required : true
8
- default : ' Add & Commit GitHub Action'
6
+ description : ' The name of the user that will be displayed as the author of the commit, defaults to author name of head commit'
7
+ required : false
9
8
author_email :
10
- description : ' The email of the user that will be displayed as the author of the commit'
11
- required : true
12
-
9
+ description : ' The email of the user that will be displayed as the author of the commit, defaults to author email of head commit'
10
+ required : false
13
11
force :
14
12
description : ' Whether to use the force option on git add, in order to bypass eventual gitignores'
15
13
required : false
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
set -eu
3
3
4
+ if [ -z " $INPUT_AUTHOR_NAME " ] # Check if the variable is empty
5
+ then AUTHOR_NAME=$( cat " $GITHUB_EVENT_PATH " | jq ' .head_commit.author.name' | sed ' s/"//g' ) # If so, fetch the author from the event
6
+ else AUTHOR_NAME=$INPUT_AUTHOR_NAME # If not, use that value
7
+ fi
8
+
9
+ if [ -z " $INPUT_AUTHOR_EMAIL " ]
10
+ then AUTHOR_EMAIL=$( cat " $GITHUB_EVENT_PATH " | jq ' .head_commit.author.email' | sed ' s/"//g' )
11
+ else AUTHOR_EMAIL=$INPUT_AUTHOR_EMAIL
12
+ fi
13
+
14
+ echo " Using '$AUTHOR_NAME ' and '$AUTHOR_EMAIL ' as author information."
15
+
4
16
# Set up .netrc file with GitHub credentials
5
17
git_setup () {
6
18
cat << - EOF > $HOME /.netrc
@@ -14,8 +26,8 @@ git_setup() {
14
26
EOF
15
27
chmod 600 $HOME /.netrc
16
28
17
- git config --global user.email
" [email protected] "
18
- git config --global user.name " Add & Commit GitHub Action "
29
+ git config --global user.email " $AUTHOR_EMAIL "
30
+ git config --global user.name " $AUTHOR_NAME "
19
31
}
20
32
21
33
add () {
52
64
add
53
65
54
66
echo " Creating commit..."
55
- git commit -m " $INPUT_MESSAGE " --author=" $INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL >"
67
+ git commit -m " $INPUT_MESSAGE " --author=" $AUTHOR_NAME <$AUTHOR_EMAIL >"
56
68
57
69
echo " Pushing to repo..."
58
70
git push --set-upstream origin " ${GITHUB_REF: 11} "
You can’t perform that action at this time.
0 commit comments