allow empty author/committer

This commit is contained in:
lichao127 2024-07-10 12:27:17 -07:00
parent cd5c7e4b8b
commit 5875c1e2e0
No known key found for this signature in database
GPG key ID: F9277D26D38C3D9A
4 changed files with 34 additions and 20 deletions

View file

@ -74,6 +74,9 @@ inputs:
draft:
description: 'Create a draft pull request. It is not possible to change draft status after creation except through the web interface'
default: false
author-as-actions:
description: 'use GitHub Actions App as the author/committer which signs the commit'
default: false
outputs:
pull-request-number:
description: 'The pull request number'

View file

@ -124,7 +124,8 @@ export async function createOrUpdateBranch(
branch: string,
branchRemoteName: string,
signoff: boolean,
addPaths: string[]
addPaths: string[],
useRestApi: boolean
): Promise<CreateOrUpdateBranchResult> {
// Get the working base.
// When a ref, it may or may not be the actual base.

View file

@ -32,6 +32,7 @@ export interface Inputs {
teamReviewers: string[]
milestone: number
draft: boolean
commitAsActions: boolean
}
export async function createPullRequest(inputs: Inputs): Promise<void> {
@ -154,24 +155,31 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
// Configure the committer and author
core.startGroup('Configuring the committer and author')
const parsedAuthor = utils.parseDisplayNameEmail(inputs.author)
const parsedCommitter = utils.parseDisplayNameEmail(inputs.committer)
git.setIdentityGitOptions([
'-c',
`author.name=${parsedAuthor.name}`,
'-c',
`author.email=${parsedAuthor.email}`,
'-c',
`committer.name=${parsedCommitter.name}`,
'-c',
`committer.email=${parsedCommitter.email}`
])
core.info(
`Configured git committer as '${parsedCommitter.name} <${parsedCommitter.email}>'`
)
core.info(
`Configured git author as '${parsedAuthor.name} <${parsedAuthor.email}>'`
)
if (inputs.commitAsActions == true) {
const parsedAuthor = ""
const parsedCommitter = ""
}
else {
const parsedAuthor = utils.parseDisplayNameEmail(inputs.author)
const parsedCommitter = utils.parseDisplayNameEmail(inputs.committer)
git.setIdentityGitOptions([
'-c',
`author.name=${parsedAuthor.name}`,
'-c',
`author.email=${parsedAuthor.email}`,
'-c',
`committer.name=${parsedCommitter.name}`,
'-c',
`committer.email=${parsedCommitter.email}`
])
core.info(
`Configured git committer as '${parsedCommitter.name} <${parsedCommitter.email}>'`
)
core.info(
`Configured git author as '${parsedAuthor.name} <${parsedAuthor.email}>'`
)
}
core.endGroup()
// Create or update the pull request branch
@ -183,7 +191,8 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
inputs.branch,
branchRemoteName,
inputs.signoff,
inputs.addPaths
inputs.addPaths,
inputs.commitAsActions
)
core.endGroup()

View file

@ -28,6 +28,7 @@ async function run(): Promise<void> {
teamReviewers: utils.getInputAsArray('team-reviewers'),
milestone: Number(core.getInput('milestone')),
draft: core.getBooleanInput('draft')
useRestApi: core.getBooleanInput('use-rest-api')
}
core.debug(`Inputs: ${inspect(inputs)}`)