@tahminator/pipeline 1.0.97 → 1.0.98
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 +2 -0
- 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
|
@@ -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({
|
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({
|