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"
99LABEL "homepage" ="https://github.com/EndBug/add-and-commit"
1010LABEL "maintainer" =
"Federico Grandi <[email protected] >" 1111
12+ RUN apk add jq
13+
1214COPY entrypoint.sh /entrypoint.sh
1315
1416ENTRYPOINT ["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'
33
44inputs :
55 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
98 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
1311 force :
1412 description : ' Whether to use the force option on git add, in order to bypass eventual gitignores'
1513 required : false
Original file line number Diff line number Diff line change 11#! /bin/sh
22set -eu
33
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+
416# Set up .netrc file with GitHub credentials
517git_setup () {
618 cat << - EOF > $HOME /.netrc
@@ -14,8 +26,8 @@ git_setup() {
1426EOF
1527 chmod 600 $HOME /.netrc
1628
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 "
1931}
2032
2133add () {
5264 add
5365
5466 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 >"
5668
5769 echo " Pushing to repo..."
5870 git push --set-upstream origin " ${GITHUB_REF: 11} "
You can’t perform that action at this time.
0 commit comments