Implement changes of v2.2.0
This commit is contained in:
@@ -5,11 +5,9 @@ inputs:
|
|||||||
author_name:
|
author_name:
|
||||||
description: The name of the user that will be displayed as the author of the commit
|
description: The name of the user that will be displayed as the author of the commit
|
||||||
required: false
|
required: false
|
||||||
default: Add & Commit GitHub Action
|
|
||||||
author_email:
|
author_email:
|
||||||
description: The email of the user that will be displayed as the author of the commit
|
description: The email of the user that will be displayed as the author of the commit
|
||||||
required: false
|
required: false
|
||||||
default: actions@github.com
|
|
||||||
force:
|
force:
|
||||||
description: Whether to use the force option on git add, in order to bypass eventual gitignores
|
description: Whether to use the force option on git add, in order to bypass eventual gitignores
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ git_setup() {
|
|||||||
EOF
|
EOF
|
||||||
chmod 600 $HOME/.netrc
|
chmod 600 $HOME/.netrc
|
||||||
|
|
||||||
git config --global user.email "actions@github.com"
|
git config --global user.email "$INPUT_AUTHOR_EMAIL"
|
||||||
git config --global user.name "Add & Commit GitHub Action"
|
git config --global user.name "$INPUT_AUTHOR_NAME"
|
||||||
}
|
}
|
||||||
|
|
||||||
add() {
|
add() {
|
||||||
|
|||||||
15
src/main.ts
15
src/main.ts
@@ -3,7 +3,22 @@ import * as shell from 'shelljs'
|
|||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
checkInputs()
|
||||||
shell.exec(path.join(__dirname, '../src/entrypoint.sh'))
|
shell.exec(path.join(__dirname, '../src/entrypoint.sh'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
core.setFailed(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.`)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user