@tahminator/pipeline 1.0.74 → 1.0.75

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.
@@ -36,11 +36,93 @@ export declare class GitHubClient {
36
36
  * @deprecated use `createWithGithubAppToken`
37
37
  */
38
38
  static createWithPatCiToken(pat: string): Promise<GitHubClient>;
39
+ /**
40
+ * Utilizes the GitHub API to create a new tag version in the given repository.
41
+ *
42
+ * @note You **must** pass in a GitHub token because the regular Github bot token
43
+ * cannot trigger actions (due to fear of recursion). You must either provide a GitHub App token or
44
+ * a GitHub PAT.
45
+ *
46
+ * @note you should use `VersioningClient` to generate `nextTag`
47
+ */
39
48
  createTag(...args: Parameters<GitHubTagManager["createTag"]>): Promise<void>;
49
+ /**
50
+ * Returns the latest stable semver tag in the repository.
51
+ */
40
52
  getLatestTag(...args: Parameters<GitHubTagManager["getLatestTag"]>): Promise<string | null>;
53
+ /**
54
+ * Write an output back to Github Actions in order to re-use / pass
55
+ * data between steps, jobs, etc.
56
+ *
57
+ * @see documentation for passing outputs between jobs [here](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job-outputs)
58
+ */
41
59
  outputToGithubOutput(...args: Parameters<GitHubOutputManager["outputToGithubOutput"]>): Promise<void>;
60
+ /**
61
+ *
62
+ * update k8s manifest repo with new tag version.
63
+ *
64
+ * @note `kustomizationFile` must look like this:
65
+ *
66
+ * ```yaml
67
+ * apiVersion: kustomize.config.k8s.io/v1beta1
68
+ * kind: Kustomization
69
+ * resources:
70
+ * - deployment.yaml
71
+ * - secrets.yaml
72
+ * - service.yaml
73
+ * - monitor.yaml
74
+ * commonLabels:
75
+ * app: instalock-web
76
+ * environment: production
77
+ * # This part specifically
78
+ * images:
79
+ * - name: tahminator/instalock-web
80
+ * newTag: a70ee0e
81
+ * ```
82
+ */
42
83
  updateK8sTagWithPR(...args: Parameters<GitHubPRManager["updateK8sTagWithPR"]>): Promise<void>;
43
84
  sendPrMessage(...args: Parameters<GitHubPRManager["sendPrMessage"]>): Promise<void>;
85
+ /**
86
+ * @note if the PR doesn't exist yet, just use `updateK8sTagWithPR` instead, since it
87
+ * creates the PR with the necessary changes and merges it for you in one call.
88
+ */
44
89
  mergePr(...args: Parameters<GitHubPRManager["mergePr"]>): Promise<void>;
90
+ /**
91
+ * Create or update a check run (the "status checks" shown on a PR/commit), dispatched by
92
+ * `action`.
93
+ */
94
+ writeStatusCheck(...args: Parameters<GitHubPRManager["writeStatusCheck"]>): Promise<{
95
+ id: number;
96
+ head_sha: string;
97
+ node_id: string;
98
+ external_id: string | null;
99
+ url: string;
100
+ html_url: string | null;
101
+ details_url: string | null;
102
+ status: "queued" | "in_progress" | "completed" | "waiting" | "requested" | "pending";
103
+ conclusion: "success" | "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required" | null;
104
+ started_at: string | null;
105
+ completed_at: string | null;
106
+ output: {
107
+ title: string | null;
108
+ summary: string | null;
109
+ text: string | null;
110
+ annotations_count: number;
111
+ annotations_url: string;
112
+ };
113
+ name: string;
114
+ check_suite: {
115
+ id: number;
116
+ } | null;
117
+ app: import("@octokit/openapi-types").components["schemas"]["nullable-integration"];
118
+ pull_requests: import("@octokit/openapi-types").components["schemas"]["pull-request-minimal"][];
119
+ deployment?: import("@octokit/openapi-types").components["schemas"]["deployment-simple"];
120
+ }>;
121
+ /**
122
+ * Confirms whether the given user is an active member of a team within an org.
123
+ *
124
+ * @note this only returns `true` for `active` memberships. A user with a `pending`
125
+ * invite (has not accepted yet) will return `false`.
126
+ */
45
127
  isTeamMember(...args: Parameters<GitHubTeamManager["isTeamMember"]>): Promise<boolean>;
46
128
  }
package/dist/gh/client.js CHANGED
@@ -56,24 +56,82 @@ export class GitHubClient {
56
56
  auth: pat,
57
57
  }), true);
58
58
  }
59
+ /**
60
+ * Utilizes the GitHub API to create a new tag version in the given repository.
61
+ *
62
+ * @note You **must** pass in a GitHub token because the regular Github bot token
63
+ * cannot trigger actions (due to fear of recursion). You must either provide a GitHub App token or
64
+ * a GitHub PAT.
65
+ *
66
+ * @note you should use `VersioningClient` to generate `nextTag`
67
+ */
59
68
  createTag(...args) {
60
69
  return this.tagManager.createTag(...args);
61
70
  }
71
+ /**
72
+ * Returns the latest stable semver tag in the repository.
73
+ */
62
74
  getLatestTag(...args) {
63
75
  return this.tagManager.getLatestTag(...args);
64
76
  }
77
+ /**
78
+ * Write an output back to Github Actions in order to re-use / pass
79
+ * data between steps, jobs, etc.
80
+ *
81
+ * @see documentation for passing outputs between jobs [here](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job-outputs)
82
+ */
65
83
  outputToGithubOutput(...args) {
66
84
  return this.outputManager.outputToGithubOutput(...args);
67
85
  }
86
+ /**
87
+ *
88
+ * update k8s manifest repo with new tag version.
89
+ *
90
+ * @note `kustomizationFile` must look like this:
91
+ *
92
+ * ```yaml
93
+ * apiVersion: kustomize.config.k8s.io/v1beta1
94
+ * kind: Kustomization
95
+ * resources:
96
+ * - deployment.yaml
97
+ * - secrets.yaml
98
+ * - service.yaml
99
+ * - monitor.yaml
100
+ * commonLabels:
101
+ * app: instalock-web
102
+ * environment: production
103
+ * # This part specifically
104
+ * images:
105
+ * - name: tahminator/instalock-web
106
+ * newTag: a70ee0e
107
+ * ```
108
+ */
68
109
  updateK8sTagWithPR(...args) {
69
110
  return this.prManager.updateK8sTagWithPR(...args);
70
111
  }
71
112
  sendPrMessage(...args) {
72
113
  return this.prManager.sendPrMessage(...args);
73
114
  }
115
+ /**
116
+ * @note if the PR doesn't exist yet, just use `updateK8sTagWithPR` instead, since it
117
+ * creates the PR with the necessary changes and merges it for you in one call.
118
+ */
74
119
  mergePr(...args) {
75
120
  return this.prManager.mergePr(...args);
76
121
  }
122
+ /**
123
+ * Create or update a check run (the "status checks" shown on a PR/commit), dispatched by
124
+ * `action`.
125
+ */
126
+ writeStatusCheck(...args) {
127
+ return this.prManager.writeStatusCheck(...args);
128
+ }
129
+ /**
130
+ * Confirms whether the given user is an active member of a team within an org.
131
+ *
132
+ * @note this only returns `true` for `active` memberships. A user with a `pending`
133
+ * invite (has not accepted yet) will return `false`.
134
+ */
77
135
  isTeamMember(...args) {
78
136
  return this.teamManager.isTeamMember(...args);
79
137
  }
@@ -1,11 +1,5 @@
1
1
  export declare class GitHubOutputManager {
2
2
  constructor();
3
- /**
4
- * Write an output back to Github Actions in order to re-use / pass
5
- * data between steps, jobs, etc.
6
- *
7
- * @see documentation for passing outputs between jobs [here](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job-outputs)
8
- */
9
3
  outputToGithubOutput({ overrideGithubOutputFile, ctx, }: {
10
4
  overrideGithubOutputFile?: string;
11
5
  ctx: Record<string, unknown>;
@@ -1,11 +1,5 @@
1
1
  export class GitHubOutputManager {
2
2
  constructor() { }
3
- /**
4
- * Write an output back to Github Actions in order to re-use / pass
5
- * data between steps, jobs, etc.
6
- *
7
- * @see documentation for passing outputs between jobs [here](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job-outputs)
8
- */
9
3
  async outputToGithubOutput({ overrideGithubOutputFile, ctx, }) {
10
4
  const githubOutputEnv = (() => {
11
5
  const v = process.env.GITHUB_OUTPUT;
@@ -1,31 +1,38 @@
1
1
  import type { Octokit } from "@octokit/rest";
2
2
  import type { Environment, OwnerString, RepoString } from "../../types";
3
+ type CheckRunStatus = "queued" | "in_progress" | "completed";
4
+ type CheckRunConclusion = "action_required" | "cancelled" | "failure" | "neutral" | "success" | "skipped" | "stale" | "timed_out";
5
+ type CheckRunOutput = {
6
+ title: string;
7
+ summary: string;
8
+ text?: string;
9
+ };
10
+ type WriteStatusCheckArgs = {
11
+ action: "create";
12
+ owner: string;
13
+ repository: string;
14
+ /**
15
+ * commit sha the check run applies to
16
+ */
17
+ sha: string;
18
+ name: string;
19
+ status?: CheckRunStatus;
20
+ conclusion?: CheckRunConclusion;
21
+ output?: CheckRunOutput;
22
+ detailsUrl?: string;
23
+ } | {
24
+ action: "update";
25
+ owner: string;
26
+ repository: string;
27
+ checkRunId: number;
28
+ status?: CheckRunStatus;
29
+ conclusion?: CheckRunConclusion;
30
+ output?: CheckRunOutput;
31
+ detailsUrl?: string;
32
+ };
3
33
  export declare class GitHubPRManager {
4
34
  private readonly client;
5
35
  constructor(client: Octokit);
6
- /**
7
- *
8
- * update k8s manifest repo with new tag version.
9
- *
10
- * @note `kustomizationFile` must look like this:
11
- *
12
- * ```yaml
13
- * apiVersion: kustomize.config.k8s.io/v1beta1
14
- * kind: Kustomization
15
- * resources:
16
- * - deployment.yaml
17
- * - secrets.yaml
18
- * - service.yaml
19
- * - monitor.yaml
20
- * commonLabels:
21
- * app: instalock-web
22
- * environment: production
23
- * # This part specifically
24
- * images:
25
- * - name: tahminator/instalock-web
26
- * newTag: a70ee0e
27
- * ```
28
- */
29
36
  updateK8sTagWithPR({ newTag, imageName, kustomizationFilePath, environment, originRepo, manifestRepo, }: {
30
37
  newTag: string;
31
38
  imageName: string;
@@ -34,16 +41,39 @@ export declare class GitHubPRManager {
34
41
  originRepo: [OwnerString, RepoString];
35
42
  manifestRepo: [OwnerString, RepoString];
36
43
  }): Promise<void>;
37
- /**
38
- * @note if the PR doesn't exist yet, just use `updateK8sTagWithPR` instead, since it
39
- * creates the PR with the necessary changes and merges it for you in one call.
40
- */
41
44
  mergePr({ prId, owner, repository, mergeMethod, }: {
42
45
  prId: number;
43
46
  owner: string;
44
47
  repository: string;
45
48
  mergeMethod?: "merge" | "squash" | "rebase";
46
49
  }): Promise<void>;
50
+ writeStatusCheck(args: WriteStatusCheckArgs): Promise<{
51
+ id: number;
52
+ head_sha: string;
53
+ node_id: string;
54
+ external_id: string | null;
55
+ url: string;
56
+ html_url: string | null;
57
+ details_url: string | null;
58
+ status: "queued" | "in_progress" | "completed" | "waiting" | "requested" | "pending";
59
+ conclusion: "success" | "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required" | null;
60
+ started_at: string | null;
61
+ completed_at: string | null;
62
+ output: {
63
+ title: string | null;
64
+ summary: string | null;
65
+ text: string | null;
66
+ annotations_count: number;
67
+ annotations_url: string;
68
+ };
69
+ name: string;
70
+ check_suite: {
71
+ id: number;
72
+ } | null;
73
+ app: import("@octokit/openapi-types").components["schemas"]["nullable-integration"];
74
+ pull_requests: import("@octokit/openapi-types").components["schemas"]["pull-request-minimal"][];
75
+ deployment?: import("@octokit/openapi-types").components["schemas"]["deployment-simple"];
76
+ }>;
47
77
  sendPrMessage({ prId, owner, repository, message, }: {
48
78
  prId: number;
49
79
  owner: string;
@@ -51,3 +81,4 @@ export declare class GitHubPRManager {
51
81
  message: string;
52
82
  }): Promise<void>;
53
83
  }
84
+ export {};
@@ -6,29 +6,6 @@ export class GitHubPRManager {
6
6
  constructor(client) {
7
7
  this.client = client;
8
8
  }
9
- /**
10
- *
11
- * update k8s manifest repo with new tag version.
12
- *
13
- * @note `kustomizationFile` must look like this:
14
- *
15
- * ```yaml
16
- * apiVersion: kustomize.config.k8s.io/v1beta1
17
- * kind: Kustomization
18
- * resources:
19
- * - deployment.yaml
20
- * - secrets.yaml
21
- * - service.yaml
22
- * - monitor.yaml
23
- * commonLabels:
24
- * app: instalock-web
25
- * environment: production
26
- * # This part specifically
27
- * images:
28
- * - name: tahminator/instalock-web
29
- * newTag: a70ee0e
30
- * ```
31
- */
32
9
  async updateK8sTagWithPR({ newTag, imageName, kustomizationFilePath, environment, originRepo, manifestRepo, }) {
33
10
  const [manifestOwner, manifestRepository] = manifestRepo;
34
11
  const [originOwner, originRepository] = originRepo;
@@ -97,10 +74,6 @@ export class GitHubPRManager {
97
74
  repository: manifestRepository,
98
75
  });
99
76
  }
100
- /**
101
- * @note if the PR doesn't exist yet, just use `updateK8sTagWithPR` instead, since it
102
- * creates the PR with the necessary changes and merges it for you in one call.
103
- */
104
77
  async mergePr({ prId, owner, repository, mergeMethod = "squash", }) {
105
78
  await this.client.rest.pulls.merge({
106
79
  owner,
@@ -109,6 +82,37 @@ export class GitHubPRManager {
109
82
  merge_method: mergeMethod,
110
83
  });
111
84
  }
85
+ async writeStatusCheck(args) {
86
+ switch (args.action) {
87
+ case "create": {
88
+ const { owner, repository, sha, name, status, conclusion, output, detailsUrl, } = args;
89
+ const { data } = await this.client.rest.checks.create({
90
+ owner,
91
+ repo: repository,
92
+ head_sha: sha,
93
+ name,
94
+ status,
95
+ conclusion,
96
+ output,
97
+ details_url: detailsUrl,
98
+ });
99
+ return data;
100
+ }
101
+ case "update": {
102
+ const { owner, repository, checkRunId, status, conclusion, output, detailsUrl, } = args;
103
+ const { data } = await this.client.rest.checks.update({
104
+ owner,
105
+ repo: repository,
106
+ check_run_id: checkRunId,
107
+ status,
108
+ conclusion,
109
+ output,
110
+ details_url: detailsUrl,
111
+ });
112
+ return data;
113
+ }
114
+ }
115
+ }
112
116
  async sendPrMessage({ prId, owner, repository, message, }) {
113
117
  await this.client.rest.issues.createComment({
114
118
  issue_number: prId,
@@ -5,21 +5,9 @@ export declare class GitHubTagManager {
5
5
  private readonly isExplicitToken;
6
6
  constructor(client: Octokit, isExplicitToken: boolean);
7
7
  private checkToken;
8
- /**
9
- * Returns the latest stable semver tag in the repository.
10
- */
11
8
  getLatestTag({ repositoryOverride, }?: {
12
9
  repositoryOverride?: [OwnerString, RepoString];
13
10
  }): Promise<string | null>;
14
- /**
15
- * Utilizes the GitHub API to create a new tag version in the given repository.
16
- *
17
- * @note You **must** pass in a GitHub token because the regular Github bot token
18
- * cannot trigger actions (due to fear of recursion). You must either provide a GitHub App token or
19
- * a GitHub PAT.
20
- *
21
- * @note you should use `VersioningClient` to generate `nextTag`
22
- */
23
11
  createTag({ nextTag, repositoryOverride, onPreTagCreate, }: {
24
12
  nextTag: string;
25
13
  repositoryOverride?: [OwnerString, RepoString];
@@ -13,9 +13,6 @@ export class GitHubTagManager {
13
13
  throw new Error("You must pass in an explicit GitHub token for this operation. You may either use a PAT or a GitHub App Token");
14
14
  }
15
15
  }
16
- /**
17
- * Returns the latest stable semver tag in the repository.
18
- */
19
16
  async getLatestTag({ repositoryOverride, } = {}) {
20
17
  const [owner, repo] = this.parseRepository(repositoryOverride);
21
18
  const { data: tags } = await this.client.rest.repos.listTags({
@@ -30,15 +27,6 @@ export class GitHubTagManager {
30
27
  })
31
28
  .sort(semver.rcompare)[0] ?? null);
32
29
  }
33
- /**
34
- * Utilizes the GitHub API to create a new tag version in the given repository.
35
- *
36
- * @note You **must** pass in a GitHub token because the regular Github bot token
37
- * cannot trigger actions (due to fear of recursion). You must either provide a GitHub App token or
38
- * a GitHub PAT.
39
- *
40
- * @note you should use `VersioningClient` to generate `nextTag`
41
- */
42
30
  async createTag({ nextTag, repositoryOverride, onPreTagCreate, }) {
43
31
  this.checkToken();
44
32
  const [owner, repo] = this.parseRepository(repositoryOverride);
@@ -2,12 +2,6 @@ import type { Octokit } from "@octokit/rest";
2
2
  export declare class GitHubTeamManager {
3
3
  private readonly client;
4
4
  constructor(client: Octokit);
5
- /**
6
- * Confirms whether the given user is an active member of a team within an org.
7
- *
8
- * @note this only returns `true` for `active` memberships. A user with a `pending`
9
- * invite (has not accepted yet) will return `false`.
10
- */
11
5
  isTeamMember({ org, teamSlug, username, }: {
12
6
  org: string;
13
7
  teamSlug: string;
@@ -3,12 +3,6 @@ export class GitHubTeamManager {
3
3
  constructor(client) {
4
4
  this.client = client;
5
5
  }
6
- /**
7
- * Confirms whether the given user is an active member of a team within an org.
8
- *
9
- * @note this only returns `true` for `active` memberships. A user with a `pending`
10
- * invite (has not accepted yet) will return `false`.
11
- */
12
6
  async isTeamMember({ org, teamSlug, username, }) {
13
7
  try {
14
8
  const { data } = await this.client.rest.teams.getMembershipForUserInOrg({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "author": "Tahmid Ahmed",
5
5
  "description": "A collection of Bun shell scripts that can be re-used in various CICD pipelines.",
6
- "version": "1.0.74",
6
+ "version": "1.0.75",
7
7
  "repository": {
8
8
  "url": "git+https://github.com/tahminator/pipeline.git"
9
9
  },