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: draft:
description: 'Create a draft pull request. It is not possible to change draft status after creation except through the web interface' description: 'Create a draft pull request. It is not possible to change draft status after creation except through the web interface'
default: false default: false
author-as-actions:
description: 'use GitHub Actions App as the author/committer which signs the commit'
default: false
outputs: outputs:
pull-request-number: pull-request-number:
description: 'The pull request number' description: 'The pull request number'

View file

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

View file

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

View file

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