feat: add output for head sha

This commit is contained in:
Peter Evans 2021-11-04 10:42:15 +09:00
parent 3c3d696d5b
commit c0a9598b0e
4 changed files with 372 additions and 1133 deletions

View file

@ -110,7 +110,8 @@ export async function createOrUpdateBranch(
const result: CreateOrUpdateBranchResult = {
action: 'none',
base: base,
hasDiffWithBase: false
hasDiffWithBase: false,
headSha: ''
}
// Save the working base changes to a temporary branch
@ -231,6 +232,9 @@ export async function createOrUpdateBranch(
result.hasDiffWithBase = await isAhead(git, base, branch)
}
// Get the pull request branch SHA
result.headSha = await git.revParse('HEAD')
// Delete the temporary branch
await git.exec(['branch', '--delete', '--force', tempBranch])
@ -241,4 +245,5 @@ interface CreateOrUpdateBranchResult {
action: string
base: string
hasDiffWithBase: boolean
headSha: string
}

View file

@ -212,6 +212,7 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
} else if (result.action == 'updated') {
core.setOutput('pull-request-operation', 'updated')
}
core.setOutput('pull-request-head-sha', result.headSha)
// Deprecated
core.exportVariable('PULL_REQUEST_NUMBER', pull.number)
core.endGroup()