Implement changes of v2.2.0

This commit is contained in:
Federico Grandi
2019-12-14 22:28:47 +01:00
parent b4fc1efdd2
commit c3549913c6
3 changed files with 17 additions and 4 deletions

View File

@@ -5,11 +5,9 @@ inputs:
author_name:
description: The name of the user that will be displayed as the author of the commit
required: false
default: Add & Commit GitHub Action
author_email:
description: The email of the user that will be displayed as the author of the commit
required: false
default: actions@github.com
force:
description: Whether to use the force option on git add, in order to bypass eventual gitignores
required: false

View File

@@ -14,8 +14,8 @@ git_setup() {
EOF
chmod 600 $HOME/.netrc
git config --global user.email "actions@github.com"
git config --global user.name "Add & Commit GitHub Action"
git config --global user.email "$INPUT_AUTHOR_EMAIL"
git config --global user.name "$INPUT_AUTHOR_NAME"
}
add() {

View File

@@ -3,7 +3,22 @@ import * as shell from 'shelljs'
import * as path from 'path'
try {
checkInputs()
shell.exec(path.join(__dirname, '../src/entrypoint.sh'))
} catch (e) {
core.setFailed(e)
}
function checkInputs() {
const eventPath = process.env.GITHUB_EVENT_PATH
if (eventPath) {
const { author } = require(eventPath).head_commit
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = author.name
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = author.email
} else {
core.warning('No event path available, unable to fetch author info.')
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = 'Add & Commit Action'
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = 'actions@github.com'
}
core.info(`Using '${process.env.INPUT_AUTHOR_NAME} <${process.env.INPUT_AUTHOR_EMAIL}>' as author.`)
}