feat: add pull-request-operation output

This commit is contained in:
Peter Evans 2021-02-01 09:57:08 +09:00
parent 2455e15969
commit b5f41d9b08
4 changed files with 56 additions and 23 deletions

View file

@ -13,6 +13,7 @@ interface Repository {
interface Pull {
number: number
html_url: string
created: boolean
}
export class GitHubHelper {
@ -55,7 +56,8 @@ export class GitHubHelper {
)
return {
number: pull.number,
html_url: pull.html_url
html_url: pull.html_url,
created: true
}
} catch (e) {
if (
@ -87,7 +89,8 @@ export class GitHubHelper {
)
return {
number: pull.number,
html_url: pull.html_url
html_url: pull.html_url,
created: false
}
}
@ -107,21 +110,13 @@ export class GitHubHelper {
inputs: Inputs,
baseRepository: string,
headRepository: string
): Promise<void> {
): Promise<Pull> {
const [headOwner] = headRepository.split('/')
const headBranch = `${headOwner}:${inputs.branch}`
// Create or update the pull request
const pull = await this.createOrUpdate(inputs, baseRepository, headBranch)
// Set outputs
core.startGroup('Setting outputs')
core.setOutput('pull-request-number', pull.number)
core.setOutput('pull-request-url', pull.html_url)
// Deprecated
core.exportVariable('PULL_REQUEST_NUMBER', pull.number)
core.endGroup()
// Set milestone, labels and assignees
const updateIssueParams = {}
if (inputs.milestone) {
@ -169,5 +164,7 @@ export class GitHubHelper {
}
}
}
return pull
}
}