mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
convert to draft on branch updates when there is a diff with base
This commit is contained in:
parent
c64379e4f4
commit
8f92797560
6 changed files with 44 additions and 41 deletions
|
@ -249,6 +249,11 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
|||
outputs.set('pull-request-operation', 'created')
|
||||
} else if (result.action == 'updated') {
|
||||
outputs.set('pull-request-operation', 'updated')
|
||||
// The pull request was updated AND the branch was updated.
|
||||
// Convert back to draft if 'draft: always-true' is set.
|
||||
if (inputs.draft.always && pull.draft !== undefined && !pull.draft) {
|
||||
await ghPull.convertToDraft(pull.node_id)
|
||||
}
|
||||
}
|
||||
core.endGroup()
|
||||
} else {
|
||||
|
|
|
@ -215,28 +215,9 @@ export class GitHubHelper {
|
|||
}
|
||||
}
|
||||
|
||||
// Convert back to draft if 'draft: always-true' is set
|
||||
if (inputs.draft.always && pull.draft !== undefined && !pull.draft) {
|
||||
await this.convertToDraft(pull.node_id)
|
||||
}
|
||||
|
||||
return pull
|
||||
}
|
||||
|
||||
private async convertToDraft(id: string): Promise<void> {
|
||||
core.info(`Converting pull request to draft`)
|
||||
await this.octokit.graphql({
|
||||
query: `mutation($pullRequestId: ID!) {
|
||||
convertPullRequestToDraft(input: {pullRequestId: $pullRequestId}) {
|
||||
pullRequest {
|
||||
isDraft
|
||||
}
|
||||
}
|
||||
}`,
|
||||
pullRequestId: id
|
||||
})
|
||||
}
|
||||
|
||||
async pushSignedCommits(
|
||||
branchCommits: Commit[],
|
||||
baseSha: string,
|
||||
|
@ -368,4 +349,18 @@ export class GitHubHelper {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
async convertToDraft(id: string): Promise<void> {
|
||||
core.info(`Converting pull request to draft`)
|
||||
await this.octokit.graphql({
|
||||
query: `mutation($pullRequestId: ID!) {
|
||||
convertPullRequestToDraft(input: {pullRequestId: $pullRequestId}) {
|
||||
pullRequest {
|
||||
isDraft
|
||||
}
|
||||
}
|
||||
}`,
|
||||
pullRequestId: id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue