accept-to-ship-action 0.4.0 → 0.4.1
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/getCheckRuns.d.ts +1 -1
- package/lib/index.js +0 -1
- package/lib/mergePullRequest.js +39 -18
- package/package.json +1 -1
package/lib/getCheckRuns.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare function getCheckRuns(owner: string, repo: string, ref: string, o
|
|
|
9
9
|
html_url: string | null;
|
|
10
10
|
details_url: string | null;
|
|
11
11
|
status: "completed" | "queued" | "in_progress";
|
|
12
|
-
conclusion: "
|
|
12
|
+
conclusion: "skipped" | "success" | "neutral" | "failure" | "cancelled" | "timed_out" | "action_required" | null;
|
|
13
13
|
started_at: string | null;
|
|
14
14
|
completed_at: string | null;
|
|
15
15
|
output: {
|
package/lib/index.js
CHANGED
|
@@ -213,7 +213,6 @@ function handlePullRequest(pullRequestNumber) {
|
|
|
213
213
|
const mergeMethod = (0, getMergeMethod_1.getMergeMethod)();
|
|
214
214
|
(0, core_1.info)(`Merging with merge method: ${mergeMethod}`);
|
|
215
215
|
yield (0, mergePullRequest_1.mergePullRequest)(owner, repo, pullRequestNumber, mergeMethod, octokit);
|
|
216
|
-
(0, core_1.setOutput)('skipped', false);
|
|
217
216
|
});
|
|
218
217
|
}
|
|
219
218
|
function run() {
|
package/lib/mergePullRequest.js
CHANGED
|
@@ -10,6 +10,7 @@ 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 core_1 = require("@actions/core");
|
|
13
14
|
const request_error_1 = require("@octokit/request-error");
|
|
14
15
|
function checkIfPullRequestMerged(owner, repo, pullRequestNumber, octokit) {
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -20,34 +21,54 @@ function checkIfPullRequestMerged(owner, repo, pullRequestNumber, octokit) {
|
|
|
20
21
|
repo,
|
|
21
22
|
pull_number: pullRequestNumber,
|
|
22
23
|
});
|
|
24
|
+
if (response.status === 204) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
23
30
|
}
|
|
24
31
|
catch (error) {
|
|
25
32
|
if (error instanceof request_error_1.RequestError) {
|
|
26
|
-
|
|
33
|
+
if (error.status === 204) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
else if (error.status === 404) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw new Error(`Failed to check if pull request is merged: [${error.status}] ${error.message}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw error;
|
|
27
45
|
}
|
|
28
|
-
}
|
|
29
|
-
if ((response === null || response === void 0 ? void 0 : response.status) === 204) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
else if ((response === null || response === void 0 ? void 0 : response.status) === 404) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
throw new Error(`Failed to check if pull request is merged: ${response === null || response === void 0 ? void 0 : response.status}`);
|
|
37
46
|
}
|
|
38
47
|
});
|
|
39
48
|
}
|
|
40
49
|
exports.checkIfPullRequestMerged = checkIfPullRequestMerged;
|
|
41
50
|
function mergePullRequest(owner, repo, pullRequestNumber, mergeMethod, octokit) {
|
|
42
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
try {
|
|
53
|
+
yield octokit.rest.pulls.merge({
|
|
54
|
+
owner,
|
|
55
|
+
repo,
|
|
56
|
+
pull_number: pullRequestNumber,
|
|
57
|
+
merge_method: mergeMethod,
|
|
58
|
+
});
|
|
59
|
+
(0, core_1.setOutput)('skipped', false);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error instanceof request_error_1.RequestError) {
|
|
63
|
+
(0, core_1.warning)(`Failed to merge pull request: [${error.status}] ${error.message}`);
|
|
64
|
+
// If it's merged by someone else in a race condition we treat it as skipped,
|
|
65
|
+
// because it's the same as someone else merged it before we try.
|
|
66
|
+
const merged = yield checkIfPullRequestMerged(owner, repo, pullRequestNumber, octokit);
|
|
67
|
+
(0, core_1.setOutput)('skipped', !merged);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
51
72
|
}
|
|
52
73
|
});
|
|
53
74
|
}
|