accept-to-ship-action 0.8.4 → 0.8.6
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/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -949,6 +949,21 @@ export type ArchiveProjectV2ItemPayload = {
|
|
|
949
949
|
/** The item archived from the project. */
|
|
950
950
|
item?: Maybe<ProjectV2Item>;
|
|
951
951
|
};
|
|
952
|
+
/** Autogenerated input type of ArchivePullRequest */
|
|
953
|
+
export type ArchivePullRequestInput = {
|
|
954
|
+
/** A unique identifier for the client performing the mutation. */
|
|
955
|
+
clientMutationId?: InputMaybe<Scalars['String']['input']>;
|
|
956
|
+
/** The Node ID of the pull request to archive. */
|
|
957
|
+
pullRequestId: Scalars['ID']['input'];
|
|
958
|
+
};
|
|
959
|
+
/** Autogenerated return type of ArchivePullRequest. */
|
|
960
|
+
export type ArchivePullRequestPayload = {
|
|
961
|
+
__typename: 'ArchivePullRequestPayload';
|
|
962
|
+
/** A unique identifier for the client performing the mutation. */
|
|
963
|
+
clientMutationId?: Maybe<Scalars['String']['output']>;
|
|
964
|
+
/** The pull request that was archived. */
|
|
965
|
+
pullRequest?: Maybe<PullRequest>;
|
|
966
|
+
};
|
|
952
967
|
/** Autogenerated input type of ArchiveRepository */
|
|
953
968
|
export type ArchiveRepositoryInput = {
|
|
954
969
|
/** A unique identifier for the client performing the mutation. */
|
|
@@ -11986,6 +12001,11 @@ export type Mutation = {
|
|
|
11986
12001
|
approveVerifiableDomain?: Maybe<ApproveVerifiableDomainPayload>;
|
|
11987
12002
|
/** Archives a ProjectV2Item */
|
|
11988
12003
|
archiveProjectV2Item?: Maybe<ArchiveProjectV2ItemPayload>;
|
|
12004
|
+
/**
|
|
12005
|
+
* Archive a pull request. Closes, locks, and marks the pull request as archived.
|
|
12006
|
+
* Only repository admins can archive pull requests.
|
|
12007
|
+
*/
|
|
12008
|
+
archivePullRequest?: Maybe<ArchivePullRequestPayload>;
|
|
11989
12009
|
/** Marks a repository as archived. */
|
|
11990
12010
|
archiveRepository?: Maybe<ArchiveRepositoryPayload>;
|
|
11991
12011
|
/** Cancels a pending invitation for an administrator to join an enterprise. */
|
|
@@ -12380,6 +12400,12 @@ export type Mutation = {
|
|
|
12380
12400
|
transferIssue?: Maybe<TransferIssuePayload>;
|
|
12381
12401
|
/** Unarchives a ProjectV2Item */
|
|
12382
12402
|
unarchiveProjectV2Item?: Maybe<UnarchiveProjectV2ItemPayload>;
|
|
12403
|
+
/**
|
|
12404
|
+
* Unarchive a pull request. Removes the archived flag from the pull request.
|
|
12405
|
+
* Does not automatically reopen or unlock the pull request. Only repository
|
|
12406
|
+
* admins can unarchive pull requests.
|
|
12407
|
+
*/
|
|
12408
|
+
unarchivePullRequest?: Maybe<UnarchivePullRequestPayload>;
|
|
12383
12409
|
/** Unarchives a repository. */
|
|
12384
12410
|
unarchiveRepository?: Maybe<UnarchiveRepositoryPayload>;
|
|
12385
12411
|
/** Unfollow an organization. */
|
|
@@ -12705,6 +12731,10 @@ export type MutationArchiveProjectV2ItemArgs = {
|
|
|
12705
12731
|
input: ArchiveProjectV2ItemInput;
|
|
12706
12732
|
};
|
|
12707
12733
|
/** The root query for implementing GraphQL mutations. */
|
|
12734
|
+
export type MutationArchivePullRequestArgs = {
|
|
12735
|
+
input: ArchivePullRequestInput;
|
|
12736
|
+
};
|
|
12737
|
+
/** The root query for implementing GraphQL mutations. */
|
|
12708
12738
|
export type MutationArchiveRepositoryArgs = {
|
|
12709
12739
|
input: ArchiveRepositoryInput;
|
|
12710
12740
|
};
|
|
@@ -13313,6 +13343,10 @@ export type MutationUnarchiveProjectV2ItemArgs = {
|
|
|
13313
13343
|
input: UnarchiveProjectV2ItemInput;
|
|
13314
13344
|
};
|
|
13315
13345
|
/** The root query for implementing GraphQL mutations. */
|
|
13346
|
+
export type MutationUnarchivePullRequestArgs = {
|
|
13347
|
+
input: UnarchivePullRequestInput;
|
|
13348
|
+
};
|
|
13349
|
+
/** The root query for implementing GraphQL mutations. */
|
|
13316
13350
|
export type MutationUnarchiveRepositoryArgs = {
|
|
13317
13351
|
input: UnarchiveRepositoryInput;
|
|
13318
13352
|
};
|
|
@@ -31032,6 +31066,21 @@ export type UnarchiveProjectV2ItemPayload = {
|
|
|
31032
31066
|
/** The item unarchived from the project. */
|
|
31033
31067
|
item?: Maybe<ProjectV2Item>;
|
|
31034
31068
|
};
|
|
31069
|
+
/** Autogenerated input type of UnarchivePullRequest */
|
|
31070
|
+
export type UnarchivePullRequestInput = {
|
|
31071
|
+
/** A unique identifier for the client performing the mutation. */
|
|
31072
|
+
clientMutationId?: InputMaybe<Scalars['String']['input']>;
|
|
31073
|
+
/** The Node ID of the pull request to unarchive. */
|
|
31074
|
+
pullRequestId: Scalars['ID']['input'];
|
|
31075
|
+
};
|
|
31076
|
+
/** Autogenerated return type of UnarchivePullRequest. */
|
|
31077
|
+
export type UnarchivePullRequestPayload = {
|
|
31078
|
+
__typename: 'UnarchivePullRequestPayload';
|
|
31079
|
+
/** A unique identifier for the client performing the mutation. */
|
|
31080
|
+
clientMutationId?: Maybe<Scalars['String']['output']>;
|
|
31081
|
+
/** The pull request that was unarchived. */
|
|
31082
|
+
pullRequest?: Maybe<PullRequest>;
|
|
31083
|
+
};
|
|
31035
31084
|
/** Autogenerated input type of UnarchiveRepository */
|
|
31036
31085
|
export type UnarchiveRepositoryInput = {
|
|
31037
31086
|
/** A unique identifier for the client performing the mutation. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Octokit } from '@octokit/core';
|
|
2
2
|
import type { Api, RestEndpointMethodTypes } from '@octokit/plugin-rest-endpoint-methods';
|
|
3
3
|
import { getMergeMethod } from './getMergeMethod.js';
|
|
4
|
-
export declare function enablePullRequestAutoMerge(owner: string, repo: string, pullRequest: RestEndpointMethodTypes['pulls']['get']['response']['data'], pullRequestId: string, mergeMethod: ReturnType<typeof getMergeMethod>, octokit: Octokit & Api): Promise<
|
|
4
|
+
export declare function enablePullRequestAutoMerge(owner: string, repo: string, pullRequest: RestEndpointMethodTypes['pulls']['get']['response']['data'], pullRequestId: string, mergeMethod: ReturnType<typeof getMergeMethod>, octokit: Octokit & Api): Promise<boolean>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { error, info, setFailed, setOutput, warning } from '@actions/core';
|
|
2
2
|
import { context } from '@actions/github';
|
|
3
|
+
import { GraphqlResponseError } from '@octokit/graphql';
|
|
3
4
|
import { RequestError } from '@octokit/request-error';
|
|
4
5
|
import { graphql } from './__graphql__/gql.js';
|
|
5
6
|
import { isPullRequestMerged } from './isPullRequestMerged.js';
|
|
@@ -44,35 +45,43 @@ export async function enablePullRequestAutoMerge(owner, repo, pullRequest, pullR
|
|
|
44
45
|
info(`Failed to comment on the Pull Request: [${requestError.status}] ${requestError.message}`);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
return true;
|
|
47
49
|
}
|
|
48
50
|
catch (requestError) {
|
|
49
51
|
if (requestError instanceof RequestError) {
|
|
50
52
|
warning(`Failed to enable auto-merge for the Pull Request: [${requestError.status}] ${requestError.message}`);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
if (merged) {
|
|
56
|
-
try {
|
|
57
|
-
const { data: pullRequest } = await octokit.rest.pulls.get({
|
|
58
|
-
owner,
|
|
59
|
-
repo,
|
|
60
|
-
pull_number: pullRequestNumber,
|
|
61
|
-
});
|
|
62
|
-
warning(`This Pull Request has been merged by: ${pullRequest.merged_by?.login} (${pullRequest.merged_by?.html_url})`);
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
warning(`This Pull Request has been merged by unknown user.`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// If it's not merged by someone else in a race condition then we treat it as a real error.
|
|
70
|
-
error(`This Pull Request remains unmerged.`);
|
|
71
|
-
setFailed(`Failed to merge this Pull Request when conditions are met.`);
|
|
53
|
+
}
|
|
54
|
+
else if (requestError instanceof GraphqlResponseError) {
|
|
55
|
+
for (const graphqlError of requestError.errors ?? []) {
|
|
56
|
+
warning(`Failed to enable auto-merge for the Pull Request: ${graphqlError.message}`);
|
|
72
57
|
}
|
|
73
58
|
}
|
|
74
59
|
else {
|
|
75
60
|
throw requestError;
|
|
76
61
|
}
|
|
62
|
+
// If it's merged by someone else in a race condition we treat it as skipped,
|
|
63
|
+
// because it's the same as someone else merged it before we try.
|
|
64
|
+
const merged = await isPullRequestMerged(owner, repo, pullRequestNumber, octokit);
|
|
65
|
+
setOutput('skipped', !merged);
|
|
66
|
+
if (merged) {
|
|
67
|
+
try {
|
|
68
|
+
const { data: pullRequest } = await octokit.rest.pulls.get({
|
|
69
|
+
owner,
|
|
70
|
+
repo,
|
|
71
|
+
pull_number: pullRequestNumber,
|
|
72
|
+
});
|
|
73
|
+
warning(`This Pull Request has been merged by: ${pullRequest.merged_by?.login} (${pullRequest.merged_by?.html_url})`);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
warning(`This Pull Request has been merged by unknown user.`);
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
// If it's not merged by someone else in a race condition then we treat it as a real error.
|
|
82
|
+
error(`This Pull Request remains unmerged.`);
|
|
83
|
+
setFailed(`Failed to enable auto-merge for this Pull Request when conditions are met.`);
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
77
86
|
}
|
|
78
87
|
}
|
package/dist/index.js
CHANGED
|
@@ -143,8 +143,12 @@ async function handlePullRequest(pullRequestNumber) {
|
|
|
143
143
|
if (pullRequestAutoMergeable.viewerCanEnableAutoMerge) {
|
|
144
144
|
const mergeMethod = getMergeMethod();
|
|
145
145
|
info(`Enabling auto-merge with merge method: ${mergeMethod}`);
|
|
146
|
-
await enablePullRequestAutoMerge(owner, repo, pullRequest, pullRequestAutoMergeable.pullRequestId, mergeMethod, octokit);
|
|
147
|
-
|
|
146
|
+
const autoMergeEnabled = await enablePullRequestAutoMerge(owner, repo, pullRequest, pullRequestAutoMergeable.pullRequestId, mergeMethod, octokit);
|
|
147
|
+
if (autoMergeEnabled) {
|
|
148
|
+
await summary
|
|
149
|
+
.addRaw(`Pull Request #${pullRequestNumber} has auto-merge enabled.`, true)
|
|
150
|
+
.write();
|
|
151
|
+
}
|
|
148
152
|
return; // No need to wait for the checks and try to merge.
|
|
149
153
|
}
|
|
150
154
|
else {
|
|
@@ -303,7 +307,9 @@ async function handlePullRequest(pullRequestNumber) {
|
|
|
303
307
|
const mergeMethod = getMergeMethod();
|
|
304
308
|
info(`Merging with merge method: ${mergeMethod}`);
|
|
305
309
|
await mergePullRequest(owner, repo, pullRequestNumber, mergeMethod, octokit);
|
|
306
|
-
summary
|
|
310
|
+
await summary
|
|
311
|
+
.addRaw(`Pull Request #${pullRequestNumber} has been merged.`, true)
|
|
312
|
+
.write();
|
|
307
313
|
}
|
|
308
314
|
async function run() {
|
|
309
315
|
info(`Event name: ${context.eventName}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accept-to-ship-action",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "This GitHub Action automatically merges approved pull requests when they include an #accept2ship trigger.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@actions/github": "^9.0.0",
|
|
32
32
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
33
33
|
"@octokit/core": "^7.0.0",
|
|
34
|
+
"@octokit/graphql": "^9.0.3",
|
|
34
35
|
"@octokit/plugin-retry": "^8.0.1",
|
|
35
36
|
"@octokit/plugin-throttling": "^11.0.1",
|
|
36
37
|
"@octokit/webhooks-types": "^7.6.1"
|
|
@@ -39,9 +40,9 @@
|
|
|
39
40
|
"@0no-co/graphqlsp": "^1.12.12",
|
|
40
41
|
"@eslint/eslintrc": "^3.3.3",
|
|
41
42
|
"@eslint/js": "^10.0.1",
|
|
42
|
-
"@graphql-codegen/cli": "6.
|
|
43
|
-
"@graphql-codegen/typescript": "5.0.
|
|
44
|
-
"@graphql-codegen/typescript-document-nodes": "5.0.
|
|
43
|
+
"@graphql-codegen/cli": "6.3.0",
|
|
44
|
+
"@graphql-codegen/typescript": "5.0.10",
|
|
45
|
+
"@graphql-codegen/typescript-document-nodes": "5.0.10",
|
|
45
46
|
"@graphql-eslint/eslint-plugin": "^4.4.0",
|
|
46
47
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
|
|
47
48
|
"@types/node": "^25.3.5",
|