Skip to content

Commit c354991

Browse files
committed
Implement changes of v2.2.0
1 parent b4fc1ef commit c354991

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

action.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ inputs:
55
author_name:
66
description: The name of the user that will be displayed as the author of the commit
77
required: false
8-
default: Add & Commit GitHub Action
98
author_email:
109
description: The email of the user that will be displayed as the author of the commit
1110
required: false
12-
1311
force:
1412
description: Whether to use the force option on git add, in order to bypass eventual gitignores
1513
required: false

src/entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ git_setup() {
1414
EOF
1515
chmod 600 $HOME/.netrc
1616

17-
git config --global user.email "[email protected]"
18-
git config --global user.name "Add & Commit GitHub Action"
17+
git config --global user.email "$INPUT_AUTHOR_EMAIL"
18+
git config --global user.name "$INPUT_AUTHOR_NAME"
1919
}
2020

2121
add() {

src/main.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@ import * as shell from 'shelljs'
33
import * as path from 'path'
44

55
try {
6+
checkInputs()
67
shell.exec(path.join(__dirname, '../src/entrypoint.sh'))
78
} catch (e) {
89
core.setFailed(e)
910
}
11+
12+
function checkInputs() {
13+
const eventPath = process.env.GITHUB_EVENT_PATH
14+
if (eventPath) {
15+
const { author } = require(eventPath).head_commit
16+
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = author.name
17+
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = author.email
18+
} else {
19+
core.warning('No event path available, unable to fetch author info.')
20+
if (!process.env.INPUT_AUTHOR_NAME) process.env.INPUT_AUTHOR_NAME = 'Add & Commit Action'
21+
if (!process.env.INPUT_AUTHOR_EMAIL) process.env.INPUT_AUTHOR_EMAIL = '[email protected]'
22+
}
23+
core.info(`Using '${process.env.INPUT_AUTHOR_NAME} <${process.env.INPUT_AUTHOR_EMAIL}>' as author.`)
24+
}

0 commit comments

Comments
 (0)