accept-to-ship-action 0.8.5 → 0.8.7

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.
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
  };
@@ -19965,6 +19999,11 @@ export type ProjectV2SingleSelectFieldOptionInput = {
19965
19999
  color: ProjectV2SingleSelectFieldOptionColor;
19966
20000
  /** The description text of the option */
19967
20001
  description: Scalars['String']['input'];
20002
+ /**
20003
+ * The ID of an existing single select option. Include this to preserve the
20004
+ * option's identity during updates, preventing item field values from being cleared.
20005
+ */
20006
+ id?: InputMaybe<Scalars['String']['input']>;
19968
20007
  /** The name of the option */
19969
20008
  name: Scalars['String']['input'];
19970
20009
  };
@@ -29890,7 +29929,7 @@ export type TagNamePatternParametersInput = {
29890
29929
  pattern: Scalars['String']['input'];
29891
29930
  };
29892
29931
  /** A team of users in an organization. */
29893
- export type Team = MemberStatusable & Node & Subscribable & {
29932
+ export type Team = MemberStatusable & Node & Subscribable & TeamReviewRequestable & {
29894
29933
  __typename: 'Team';
29895
29934
  /** A list of teams that are ancestors of this team. */
29896
29935
  ancestors: TeamConnection;
@@ -30780,6 +30819,15 @@ export type TeamReviewAssignmentAlgorithm =
30780
30819
  'LOAD_BALANCE'
30781
30820
  /** Alternate reviews between each team member */
30782
30821
  | 'ROUND_ROBIN';
30822
+ /** Represents a team that can be requested to review a pull request. */
30823
+ export type TeamReviewRequestable = {
30824
+ /** The Node ID of the TeamReviewRequestable object */
30825
+ id: Scalars['ID']['output'];
30826
+ /** The name of the team. */
30827
+ name: Scalars['String']['output'];
30828
+ /** A unique, human-readable identifier for the team. */
30829
+ slug: Scalars['String']['output'];
30830
+ };
30783
30831
  /** The role of a user on a team. */
30784
30832
  export type TeamRole =
30785
30833
  /** User has admin rights on the team. */
@@ -31032,6 +31080,21 @@ export type UnarchiveProjectV2ItemPayload = {
31032
31080
  /** The item unarchived from the project. */
31033
31081
  item?: Maybe<ProjectV2Item>;
31034
31082
  };
31083
+ /** Autogenerated input type of UnarchivePullRequest */
31084
+ export type UnarchivePullRequestInput = {
31085
+ /** A unique identifier for the client performing the mutation. */
31086
+ clientMutationId?: InputMaybe<Scalars['String']['input']>;
31087
+ /** The Node ID of the pull request to unarchive. */
31088
+ pullRequestId: Scalars['ID']['input'];
31089
+ };
31090
+ /** Autogenerated return type of UnarchivePullRequest. */
31091
+ export type UnarchivePullRequestPayload = {
31092
+ __typename: 'UnarchivePullRequestPayload';
31093
+ /** A unique identifier for the client performing the mutation. */
31094
+ clientMutationId?: Maybe<Scalars['String']['output']>;
31095
+ /** The pull request that was unarchived. */
31096
+ pullRequest?: Maybe<PullRequest>;
31097
+ };
31035
31098
  /** Autogenerated input type of UnarchiveRepository */
31036
31099
  export type UnarchiveRepositoryInput = {
31037
31100
  /** 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<void>;
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
- // If it's merged by someone else in a race condition we treat it as skipped,
52
- // because it's the same as someone else merged it before we try.
53
- const merged = await isPullRequestMerged(owner, repo, pullRequestNumber, octokit);
54
- setOutput('skipped', !merged);
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
- summary.addRaw(`Pull Request #${pullRequestNumber} has auto-merge enabled.`, true);
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.addRaw(`Pull Request #${pullRequestNumber} has been merged.`, true);
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.5",
3
+ "version": "0.8.7",
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.2.1",
43
- "@graphql-codegen/typescript": "5.0.9",
44
- "@graphql-codegen/typescript-document-nodes": "5.0.9",
43
+ "@graphql-codegen/cli": "6.3.1",
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",