-
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gather information from The GitHub Event (#10)
* addind jq to dockerfile and unsing info from head commit * remove inputs * remove quotes from author information * author and email not from input - ignored files from intellij * setting author name and email if given as input * remove over-the-top echoing * Fix typos & formatting * Try to fix checks * Fix checks The new check works the opposite way
- Loading branch information
1 parent
7a1f5ec
commit 3f7ee98
Showing
4 changed files
with
23 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ LABEL "repository"="https://github.com/EndBug/add-and-commit" | |
LABEL "homepage"="https://github.com/EndBug/add-and-commit" | ||
LABEL "maintainer"="Federico Grandi <[email protected]>" | ||
|
||
RUN apk add jq | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
ENTRYPOINT ["sh", "/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
|
||
inputs: | ||
author_name: | ||
description: 'The name of the user that will be displayed as the author of the commit' | ||
required: true | ||
default: 'Add & Commit GitHub Action' | ||
description: 'The name of the user that will be displayed as the author of the commit, defaults to author name of head commit' | ||
required: false | ||
author_email: | ||
description: 'The email of the user that will be displayed as the author of the commit' | ||
required: true | ||
default: '[email protected]' | ||
description: 'The email of the user that will be displayed as the author of the commit, defaults to author email of head commit' | ||
required: false | ||
force: | ||
description: 'Whether to use the force option on git add, in order to bypass eventual gitignores' | ||
required: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
if [ -z "$INPUT_AUTHOR_NAME" ] # Check if the variable is empty | ||
then AUTHOR_NAME=$(cat "$GITHUB_EVENT_PATH" | jq '.head_commit.author.name' | sed 's/"//g') # If so, fetch the author from the event | ||
else AUTHOR_NAME=$INPUT_AUTHOR_NAME # If not, use that value | ||
fi | ||
|
||
if [ -z "$INPUT_AUTHOR_EMAIL" ] | ||
then AUTHOR_EMAIL=$(cat "$GITHUB_EVENT_PATH" | jq '.head_commit.author.email' | sed 's/"//g') | ||
else AUTHOR_EMAIL=$INPUT_AUTHOR_EMAIL | ||
fi | ||
|
||
echo "Using '$AUTHOR_NAME' and '$AUTHOR_EMAIL' as author information." | ||
|
||
# Set up .netrc file with GitHub credentials | ||
git_setup() { | ||
cat <<- EOF > $HOME/.netrc | ||
|
@@ -14,8 +26,8 @@ git_setup() { | |
EOF | ||
chmod 600 $HOME/.netrc | ||
|
||
git config --global user.email "[email protected]" | ||
git config --global user.name "Add & Commit GitHub Action" | ||
git config --global user.email "$AUTHOR_EMAIL" | ||
git config --global user.name "$AUTHOR_NAME" | ||
} | ||
|
||
add() { | ||
|
@@ -52,7 +64,7 @@ then | |
add | ||
|
||
echo "Creating commit..." | ||
git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" | ||
git commit -m "$INPUT_MESSAGE" --author="$AUTHOR_NAME <$AUTHOR_EMAIL>" | ||
|
||
echo "Pushing to repo..." | ||
git push --set-upstream origin "${GITHUB_REF:11}" | ||
|