accept-to-ship-action 0.3.16 → 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/.vscode/settings.json +6 -0
- package/lib/getCheckRuns.d.ts +1 -1
- package/lib/index.js +1 -0
- package/lib/mergePullRequest.js +39 -18
- package/package.json +2 -2
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
|
@@ -218,6 +218,7 @@ function handlePullRequest(pullRequestNumber) {
|
|
|
218
218
|
function run() {
|
|
219
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
220
220
|
(0, core_1.info)(`Event name: ${github_1.context.eventName}`);
|
|
221
|
+
(0, core_1.setOutput)('skipped', true);
|
|
221
222
|
switch (github_1.context.eventName) {
|
|
222
223
|
case 'pull_request':
|
|
223
224
|
yield (() => __awaiter(this, void 0, void 0, function* () {
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accept-to-ship-action",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/CatChen/accept-to-ship-action#readme",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@serverless-guru/prettier-plugin-import-order": "^0.
|
|
26
|
+
"@serverless-guru/prettier-plugin-import-order": "^0.3.0",
|
|
27
27
|
"@types/node": "^18.11.3",
|
|
28
28
|
"@typescript-eslint/eslint-plugin": "^5.40.1",
|
|
29
29
|
"@typescript-eslint/parser": "^5.40.1",
|