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
39
dist/index.js
vendored
39
dist/index.js
vendored
|
@ -495,6 +495,11 @@ function createPullRequest(inputs) {
|
|||
}
|
||||
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) {
|
||||
yield ghPull.convertToDraft(pull.node_id);
|
||||
}
|
||||
}
|
||||
core.endGroup();
|
||||
}
|
||||
|
@ -1306,28 +1311,9 @@ class GitHubHelper {
|
|||
throw e;
|
||||
}
|
||||
}
|
||||
// Convert back to draft if 'draft: always-true' is set
|
||||
if (inputs.draft.always && pull.draft !== undefined && !pull.draft) {
|
||||
yield this.convertToDraft(pull.node_id);
|
||||
}
|
||||
return pull;
|
||||
});
|
||||
}
|
||||
convertToDraft(id) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`Converting pull request to draft`);
|
||||
yield this.octokit.graphql({
|
||||
query: `mutation($pullRequestId: ID!) {
|
||||
convertPullRequestToDraft(input: {pullRequestId: $pullRequestId}) {
|
||||
pullRequest {
|
||||
isDraft
|
||||
}
|
||||
}
|
||||
}`,
|
||||
pullRequestId: id
|
||||
});
|
||||
});
|
||||
}
|
||||
pushSignedCommits(branchCommits, baseSha, repoPath, branchRepository, branch) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let headCommit = {
|
||||
|
@ -1401,6 +1387,21 @@ class GitHubHelper {
|
|||
}
|
||||
});
|
||||
}
|
||||
convertToDraft(id) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.info(`Converting pull request to draft`);
|
||||
yield this.octokit.graphql({
|
||||
query: `mutation($pullRequestId: ID!) {
|
||||
convertPullRequestToDraft(input: {pullRequestId: $pullRequestId}) {
|
||||
pullRequest {
|
||||
isDraft
|
||||
}
|
||||
}
|
||||
}`,
|
||||
pullRequestId: id
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.GitHubHelper = GitHubHelper;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue