accept-to-ship-action 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/getWorkflowRunJobs.js +2 -2
- package/lib/mergePullRequest.js +23 -1
- package/package.json +1 -1
|
@@ -13,12 +13,12 @@ exports.getWorkflowRunJobs = void 0;
|
|
|
13
13
|
const github_1 = require("@actions/github");
|
|
14
14
|
function getWorkflowRunJobs(owner, repo, octokit) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const
|
|
16
|
+
const { data: { jobs }, } = yield octokit.rest.actions.listJobsForWorkflowRun({
|
|
17
17
|
owner,
|
|
18
18
|
repo,
|
|
19
19
|
run_id: github_1.context.runId,
|
|
20
20
|
});
|
|
21
|
-
return
|
|
21
|
+
return jobs;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
exports.getWorkflowRunJobs = getWorkflowRunJobs;
|
package/lib/mergePullRequest.js
CHANGED
|
@@ -10,7 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.mergePullRequest = exports.checkIfPullRequestMerged = void 0;
|
|
13
|
+
const console_1 = require("console");
|
|
13
14
|
const core_1 = require("@actions/core");
|
|
15
|
+
const github_1 = require("@actions/github");
|
|
14
16
|
const request_error_1 = require("@octokit/request-error");
|
|
15
17
|
function checkIfPullRequestMerged(owner, repo, pullRequestNumber, octokit) {
|
|
16
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -57,10 +59,30 @@ function mergePullRequest(owner, repo, pullRequestNumber, mergeMethod, octokit)
|
|
|
57
59
|
merge_method: mergeMethod,
|
|
58
60
|
});
|
|
59
61
|
(0, core_1.setOutput)('skipped', false);
|
|
62
|
+
try {
|
|
63
|
+
(0, console_1.info)(`Run ID: ${github_1.context.runId}`);
|
|
64
|
+
const { data: job } = yield octokit.rest.actions.getWorkflowRun({
|
|
65
|
+
owner,
|
|
66
|
+
repo,
|
|
67
|
+
run_id: github_1.context.runId,
|
|
68
|
+
});
|
|
69
|
+
(0, console_1.info)(`Job ID: ${job.id} (${job.html_url})`);
|
|
70
|
+
yield octokit.rest.pulls.createReviewComment({
|
|
71
|
+
owner,
|
|
72
|
+
repo,
|
|
73
|
+
pull_number: pullRequestNumber,
|
|
74
|
+
body: 'This Pull Request is closed by a GitHub Action:\n\n' + job.html_url,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (requestError) {
|
|
78
|
+
if (requestError instanceof request_error_1.RequestError) {
|
|
79
|
+
(0, console_1.info)(`Failed to comment on the Pull Request: [${requestError.status}] ${requestError.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
60
82
|
}
|
|
61
83
|
catch (requestError) {
|
|
62
84
|
if (requestError instanceof request_error_1.RequestError) {
|
|
63
|
-
(0, core_1.warning)(`Failed to merge
|
|
85
|
+
(0, core_1.warning)(`Failed to merge the Pull Request: [${requestError.status}] ${requestError.message}`);
|
|
64
86
|
// If it's merged by someone else in a race condition we treat it as skipped,
|
|
65
87
|
// because it's the same as someone else merged it before we try.
|
|
66
88
|
const merged = yield checkIfPullRequestMerged(owner, repo, pullRequestNumber, octokit);
|