Add inputs for committer-name and committer-email
This commit is contained in:
parent
6342438c4e
commit
d3dc225920
|
@ -6,10 +6,14 @@ inputs:
|
|||
required: true
|
||||
commit-message:
|
||||
description: 'The message to use when committing changes.'
|
||||
author-email:
|
||||
description: 'The email address of the commit author.'
|
||||
author-name:
|
||||
description: 'The name of the commit author.'
|
||||
author-email:
|
||||
description: 'The email address of the commit author.'
|
||||
committer-name:
|
||||
description: 'The name of the committer.'
|
||||
committer-email:
|
||||
description: 'The email address of the committer.'
|
||||
title:
|
||||
description: 'The title of the pull request.'
|
||||
body:
|
||||
|
|
8
dist/index.js
vendored
8
dist/index.js
vendored
|
@ -978,8 +978,10 @@ async function run() {
|
|||
const inputs = {
|
||||
token: core.getInput("token"),
|
||||
commitMessage: core.getInput("commit-message"),
|
||||
commitAuthorEmail: core.getInput("author-email"),
|
||||
commitAuthorName: core.getInput("author-name"),
|
||||
commitAuthorEmail: core.getInput("author-email"),
|
||||
committerName: core.getInput("committer-name"),
|
||||
committerEmail: core.getInput("committer-email"),
|
||||
title: core.getInput("title"),
|
||||
body: core.getInput("body"),
|
||||
labels: core.getInput("labels"),
|
||||
|
@ -999,8 +1001,10 @@ async function run() {
|
|||
// Set environment variables from inputs.
|
||||
if (inputs.token) process.env.GITHUB_TOKEN = inputs.token;
|
||||
if (inputs.commitMessage) process.env.COMMIT_MESSAGE = inputs.commitMessage;
|
||||
if (inputs.commitAuthorEmail) process.env.COMMIT_AUTHOR_EMAIL = inputs.commitAuthorEmail;
|
||||
if (inputs.commitAuthorName) process.env.COMMIT_AUTHOR_NAME = inputs.commitAuthorName;
|
||||
if (inputs.commitAuthorEmail) process.env.COMMIT_AUTHOR_EMAIL = inputs.commitAuthorEmail;
|
||||
if (inputs.committerName) process.env.COMMITTER_NAME = inputs.committerName;
|
||||
if (inputs.committerEmail) process.env.COMMITTER_EMAIL = inputs.committerEmail;
|
||||
if (inputs.title) process.env.PULL_REQUEST_TITLE = inputs.title;
|
||||
if (inputs.body) process.env.PULL_REQUEST_BODY = inputs.body;
|
||||
if (inputs.labels) process.env.PULL_REQUEST_LABELS = inputs.labels;
|
||||
|
|
29
dist/src/create-pull-request.py
vendored
29
dist/src/create-pull-request.py
vendored
|
@ -44,12 +44,6 @@ def get_author_default(event_name, event_data):
|
|||
return email, name
|
||||
|
||||
|
||||
def set_git_config(git, email, name):
|
||||
print("Configuring git user as '%s <%s>'" % (name, email))
|
||||
git.config("--global", "user.email", '"%s"' % email)
|
||||
git.config("--global", "user.name", '"%s"' % name)
|
||||
|
||||
|
||||
def set_git_remote_url(git, token, github_repository):
|
||||
git.remote(
|
||||
"set-url",
|
||||
|
@ -229,15 +223,26 @@ event_name = os.environ["GITHUB_EVENT_NAME"]
|
|||
# Get the JSON event data
|
||||
event_data = get_github_event(os.environ["GITHUB_EVENT_PATH"])
|
||||
|
||||
# Set the repo to the working directory
|
||||
repo = Repo(os.getcwd())
|
||||
# Get the default for author email and name
|
||||
author_email, author_name = get_author_default(event_name, event_data)
|
||||
# Set commit author overrides
|
||||
author_email = os.getenv("COMMIT_AUTHOR_EMAIL", author_email)
|
||||
# Set author name and email overrides
|
||||
author_name = os.getenv("COMMIT_AUTHOR_NAME", author_name)
|
||||
# Set git configuration
|
||||
set_git_config(repo.git, author_email, author_name)
|
||||
author_email = os.getenv("COMMIT_AUTHOR_EMAIL", author_email)
|
||||
# Set committer name and email overrides
|
||||
committer_name = os.getenv("COMMITTER_NAME", author_name)
|
||||
committer_email = os.getenv("COMMITTER_EMAIL", author_email)
|
||||
|
||||
# Set the repo to the working directory
|
||||
repo = Repo(os.getcwd())
|
||||
# Set git environment. This will not persist after the action completes.
|
||||
print("Configuring git author as '%s <%s>'" % (author_name, author_email))
|
||||
print("Configuring git committer as '%s <%s>'" % (committer_name, committer_email))
|
||||
repo.git.update_environment(
|
||||
GIT_AUTHOR_NAME=author_name,
|
||||
GIT_AUTHOR_EMAIL=author_email,
|
||||
GIT_COMMITTER_NAME=committer_name,
|
||||
GIT_COMMITTER_EMAIL=committer_email,
|
||||
)
|
||||
# Update URL for the 'origin' remote
|
||||
set_git_remote_url(repo.git, github_token, github_repository)
|
||||
|
||||
|
|
8
index.js
8
index.js
|
@ -23,8 +23,10 @@ async function run() {
|
|||
const inputs = {
|
||||
token: core.getInput("token"),
|
||||
commitMessage: core.getInput("commit-message"),
|
||||
commitAuthorEmail: core.getInput("author-email"),
|
||||
commitAuthorName: core.getInput("author-name"),
|
||||
commitAuthorEmail: core.getInput("author-email"),
|
||||
committerName: core.getInput("committer-name"),
|
||||
committerEmail: core.getInput("committer-email"),
|
||||
title: core.getInput("title"),
|
||||
body: core.getInput("body"),
|
||||
labels: core.getInput("labels"),
|
||||
|
@ -44,8 +46,10 @@ async function run() {
|
|||
// Set environment variables from inputs.
|
||||
if (inputs.token) process.env.GITHUB_TOKEN = inputs.token;
|
||||
if (inputs.commitMessage) process.env.COMMIT_MESSAGE = inputs.commitMessage;
|
||||
if (inputs.commitAuthorEmail) process.env.COMMIT_AUTHOR_EMAIL = inputs.commitAuthorEmail;
|
||||
if (inputs.commitAuthorName) process.env.COMMIT_AUTHOR_NAME = inputs.commitAuthorName;
|
||||
if (inputs.commitAuthorEmail) process.env.COMMIT_AUTHOR_EMAIL = inputs.commitAuthorEmail;
|
||||
if (inputs.committerName) process.env.COMMITTER_NAME = inputs.committerName;
|
||||
if (inputs.committerEmail) process.env.COMMITTER_EMAIL = inputs.committerEmail;
|
||||
if (inputs.title) process.env.PULL_REQUEST_TITLE = inputs.title;
|
||||
if (inputs.body) process.env.PULL_REQUEST_BODY = inputs.body;
|
||||
if (inputs.labels) process.env.PULL_REQUEST_LABELS = inputs.labels;
|
||||
|
|
2
package-lock.json
generated
2
package-lock.json
generated
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "create-pull-request",
|
||||
"version": "1.7.0",
|
||||
"version": "1.8.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "create-pull-request",
|
||||
"version": "1.8.0",
|
||||
"version": "1.9.0",
|
||||
"description": "Creates a pull request for changes to your repository in the actions workspace",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -44,12 +44,6 @@ def get_author_default(event_name, event_data):
|
|||
return email, name
|
||||
|
||||
|
||||
def set_git_config(git, email, name):
|
||||
print("Configuring git user as '%s <%s>'" % (name, email))
|
||||
git.config("--global", "user.email", '"%s"' % email)
|
||||
git.config("--global", "user.name", '"%s"' % name)
|
||||
|
||||
|
||||
def set_git_remote_url(git, token, github_repository):
|
||||
git.remote(
|
||||
"set-url",
|
||||
|
@ -229,15 +223,26 @@ event_name = os.environ["GITHUB_EVENT_NAME"]
|
|||
# Get the JSON event data
|
||||
event_data = get_github_event(os.environ["GITHUB_EVENT_PATH"])
|
||||
|
||||
# Set the repo to the working directory
|
||||
repo = Repo(os.getcwd())
|
||||
# Get the default for author email and name
|
||||
author_email, author_name = get_author_default(event_name, event_data)
|
||||
# Set commit author overrides
|
||||
author_email = os.getenv("COMMIT_AUTHOR_EMAIL", author_email)
|
||||
# Set author name and email overrides
|
||||
author_name = os.getenv("COMMIT_AUTHOR_NAME", author_name)
|
||||
# Set git configuration
|
||||
set_git_config(repo.git, author_email, author_name)
|
||||
author_email = os.getenv("COMMIT_AUTHOR_EMAIL", author_email)
|
||||
# Set committer name and email overrides
|
||||
committer_name = os.getenv("COMMITTER_NAME", author_name)
|
||||
committer_email = os.getenv("COMMITTER_EMAIL", author_email)
|
||||
|
||||
# Set the repo to the working directory
|
||||
repo = Repo(os.getcwd())
|
||||
# Set git environment. This will not persist after the action completes.
|
||||
print("Configuring git author as '%s <%s>'" % (author_name, author_email))
|
||||
print("Configuring git committer as '%s <%s>'" % (committer_name, committer_email))
|
||||
repo.git.update_environment(
|
||||
GIT_AUTHOR_NAME=author_name,
|
||||
GIT_AUTHOR_EMAIL=author_email,
|
||||
GIT_COMMITTER_NAME=committer_name,
|
||||
GIT_COMMITTER_EMAIL=committer_email,
|
||||
)
|
||||
# Update URL for the 'origin' remote
|
||||
set_git_remote_url(repo.git, github_token, github_repository)
|
||||
|
||||
|
|
Loading…
Reference in a new issue