@tahminator/pipeline 1.0.97 → 1.0.98-beta.g290c807e
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/README.md +11 -1
- package/dist/gh/pr/index.d.ts +7 -1
- package/dist/gh/pr/index.js +23 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ bun run src/index.ts
|
|
|
30
30
|
> [!WARNING]
|
|
31
31
|
> This repository is iterating quickly & as such may have rough edges. I will always be happy to respond to & fix any issues anyone may have :)
|
|
32
32
|
|
|
33
|
-
The setup action's `INSTALL_BREW`, `INSTALL_PROTOC`, and
|
|
33
|
+
The setup action's `INSTALL_BREW`, `INSTALL_PROTOC`, `INSTALL_MIGRATE`, and
|
|
34
34
|
`INSTALL_PROTO_DEPENDENCIES` options use Homebrew preinstalled at
|
|
35
35
|
`/home/linuxbrew/.linuxbrew` on GitHub-hosted Ubuntu runners. Setup adds it to
|
|
36
36
|
the job's `PATH` and disables automatic updates, using the runner image's
|
|
@@ -327,6 +327,8 @@ await client.updateK8sTagWithPR({
|
|
|
327
327
|
environment: "production",
|
|
328
328
|
originRepo: ["tahminator", "pipeline"],
|
|
329
329
|
manifestRepo: ["tahminator", "infra"],
|
|
330
|
+
// optional: max PR merge attempts (2s apart) before throwing; defaults to 10
|
|
331
|
+
mergeAttempts: 10,
|
|
330
332
|
});
|
|
331
333
|
|
|
332
334
|
await client.sendPrMessage({
|
|
@@ -520,6 +522,14 @@ For an explicit cache key, set both `JAVA_CACHE_KEY` and `JAVA_CACHE_PATH`. This
|
|
|
520
522
|
|
|
521
523
|
With `INSTALL_PNPM: "true"`, set `PNPM_CACHE: "true"` to cache the pnpm store. `PNPM_CACHE_DEPENDENCY_PATH` accepts newline-separated lockfiles (default `pnpm-lock.yaml`), and `PNPM_PACKAGE_JSON_FILE` selects the package manifest (default `package.json`). Project dependencies must still be installed separately.
|
|
522
524
|
|
|
525
|
+
`INSTALL_MIGRATE: "true"` installs the [golang-migrate](https://github.com/golang-migrate/migrate) CLI with `brew install golang-migrate` and turns on the Homebrew setup. The version is whatever the runner's Homebrew formula provides. The formula ships golang-migrate's default drivers: every source driver and most databases (postgres, pgx/pgx5, mysql, sqlserver, mongodb, cassandra, clickhouse, cockroachdb, yugabytedb, redshift, spanner, firebird, neo4j, rqlite), but not `sqlite`, `sqlite3`, `sqlcipher`, `snowflake`, or `ql`.
|
|
526
|
+
|
|
527
|
+
```yaml
|
|
528
|
+
- uses: tahminator/pipeline/actions/setup@<version>
|
|
529
|
+
with:
|
|
530
|
+
INSTALL_MIGRATE: "true"
|
|
531
|
+
```
|
|
532
|
+
|
|
523
533
|
### `NPMClient`
|
|
524
534
|
|
|
525
535
|
Interface with NPM registry in order to publish packages to `npmjs.com`
|
package/dist/gh/pr/index.d.ts
CHANGED
|
@@ -51,13 +51,19 @@ export declare class GitHubPRManager {
|
|
|
51
51
|
private readonly client;
|
|
52
52
|
constructor(client: Octokit);
|
|
53
53
|
uploadDirectoryContents({ owner, repository, sourceDirectory, directory, message, branch, }: UploadDirectoryContentsArgs): Promise<void>;
|
|
54
|
-
updateK8sTagWithPR({ newTag, imageName, kustomizationFilePath, environment, originRepo, manifestRepo, }: {
|
|
54
|
+
updateK8sTagWithPR({ newTag, imageName, kustomizationFilePath, environment, originRepo, manifestRepo, mergeAttempts, }: {
|
|
55
55
|
newTag: string;
|
|
56
56
|
imageName: string;
|
|
57
57
|
kustomizationFilePath: string;
|
|
58
58
|
environment: Environment;
|
|
59
59
|
originRepo: [OwnerString, RepoString];
|
|
60
60
|
manifestRepo: [OwnerString, RepoString];
|
|
61
|
+
/**
|
|
62
|
+
* max number of times to try merging the created PR before failing
|
|
63
|
+
*
|
|
64
|
+
* @default 10
|
|
65
|
+
*/
|
|
66
|
+
mergeAttempts?: number;
|
|
61
67
|
}): Promise<void>;
|
|
62
68
|
mergePr({ prId, owner, repository, mergeMethod, }: {
|
|
63
69
|
prId: number;
|
package/dist/gh/pr/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export class GitHubPRManager {
|
|
|
49
49
|
sha: commit.sha,
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
async updateK8sTagWithPR({ newTag, imageName, kustomizationFilePath, environment, originRepo, manifestRepo, }) {
|
|
52
|
+
async updateK8sTagWithPR({ newTag, imageName, kustomizationFilePath, environment, originRepo, manifestRepo, mergeAttempts = 10, }) {
|
|
53
53
|
const [manifestOwner, manifestRepository] = manifestRepo;
|
|
54
54
|
const [originOwner, originRepository] = originRepo;
|
|
55
55
|
const newBranchName = `${imageName}-${newTag}-${Utils.generateShortId()}`;
|
|
@@ -111,11 +111,29 @@ export class GitHubPRManager {
|
|
|
111
111
|
base: baseBranch,
|
|
112
112
|
body: `Automated image tag change to ${newTag} for ${imageName} in ${environment} triggered by [${originOwner}/${originRepository}](https://github.com/${originOwner}/${originRepository}).`,
|
|
113
113
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
let lastMergeError;
|
|
115
|
+
const merged = await Utils.waitUntil({
|
|
116
|
+
attempts: mergeAttempts,
|
|
117
|
+
intervalMs: 2000,
|
|
118
|
+
predicate: async (attempt) => {
|
|
119
|
+
try {
|
|
120
|
+
await this.mergePr({
|
|
121
|
+
prId: pr.number,
|
|
122
|
+
owner: manifestOwner,
|
|
123
|
+
repository: manifestRepository,
|
|
124
|
+
});
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
lastMergeError = e;
|
|
129
|
+
console.warn(`Failed to merge PR #${pr.number} (${attempt}/${mergeAttempts}):`, e);
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
},
|
|
118
133
|
});
|
|
134
|
+
if (!merged) {
|
|
135
|
+
throw new Error(`Failed to merge PR #${pr.number} after ${mergeAttempts} attempts`, { cause: lastMergeError });
|
|
136
|
+
}
|
|
119
137
|
}
|
|
120
138
|
async mergePr({ prId, owner, repository, mergeMethod = "squash", }) {
|
|
121
139
|
await this.client.rest.pulls.merge({
|
package/package.json
CHANGED