Update all pagesDeployer.deploy() and getDeployPath() call sites to pass the owner name, matching the updated signature. Flatten org/repo names with slashes for mononoke config directory paths.
| @@ -232,7 +232,7 @@ | ||
| 232 | 232 | if (!runner) { |
| 233 | 233 | return reply.code(503).send({ error: "Canopy not enabled" }); |
| 234 | 234 | } |
| 235 | const { repo } = request.params; | |
| 235 | const { owner, repo } = request.params; | |
| 236 | 236 | const { ref } = (request.body as any) ?? {}; |
| 237 | 237 | const branch = ref || "main"; |
| 238 | 238 | const bridgeUrl = |
| @@ -259,7 +259,7 @@ | ||
| 259 | 259 | // Deploy pages if applicable |
| 260 | 260 | const pagesDeployer = (app as any).pagesDeployer; |
| 261 | 261 | if (pagesDeployer) { |
| 262 | void pagesDeployer.deploy(repo, branch).catch((err: any) => { | |
| 262 | void pagesDeployer.deploy(owner, repo, branch).catch((err: any) => { | |
| 263 | 263 | app.log.error({ err, repo, branch }, "Pages deployment failed (manual trigger)"); |
| 264 | 264 | }); |
| 265 | 265 | } |
| 266 | 266 | |
| @@ -475,7 +475,7 @@ | ||
| 475 | 475 | |
| 476 | 476 | // Undeploy old deploy path if pages disabled or domain changed |
| 477 | 477 | const pagesDeployer = (app as any).pagesDeployer; |
| 478 | const oldDeployInfo = pagesDeployer?.getDeployPath(repoRow.name); | |
| 478 | const oldDeployInfo = pagesDeployer?.getDeployPath(repoRow.owner_name, repoRow.name); | |
| 479 | 479 | if (pagesDeployer && oldDeployInfo) { |
| 480 | 480 | if (updates.pages_enabled === false || |
| 481 | 481 | (updates.pages_domain !== undefined && updates.pages_domain !== repoRow.pages_domain)) { |
| @@ -487,7 +487,7 @@ | ||
| 487 | 487 | |
| 488 | 488 | // Trigger pages deploy if enabled |
| 489 | 489 | if (pagesDeployer && (updates.pages_enabled === true || updates.pages_domain !== undefined)) { |
| 490 | void pagesDeployer.deploy(repoRow.name, repoRow.default_branch ?? "main").catch( | |
| 490 | void pagesDeployer.deploy(repoRow.owner_name, repoRow.name, repoRow.default_branch ?? "main").catch( | |
| 491 | 491 | (err: any) => app.log.error({ err, repo: repoRow.name }, "Initial pages deploy failed") |
| 492 | 492 | ); |
| 493 | 493 | } |
| 494 | 494 | |
| @@ -109,10 +109,14 @@ | ||
| 109 | 109 | // Deploy pages if applicable |
| 110 | 110 | if (this.pagesDeployer) { |
| 111 | 111 | const repo = this.db |
| 112 | .prepare(`SELECT default_branch FROM repos WHERE name = ? AND pages_enabled = 1`) | |
| 112 | .prepare( | |
| 113 | `SELECT r.default_branch, rwo.owner_name FROM repos r | |
| 114 | JOIN repos_with_owner rwo ON rwo.id = r.id | |
| 115 | WHERE r.name = ? AND r.pages_enabled = 1` | |
| 116 | ) | |
| 113 | 117 | .get(repoName) as any; |
| 114 | 118 | if (repo && bookmark.name === (repo.default_branch ?? "main")) { |
| 115 | void this.pagesDeployer.deploy(repoName, bookmark.name).catch((err) => { | |
| 119 | void this.pagesDeployer.deploy(repo.owner_name, repoName, bookmark.name).catch((err) => { | |
| 116 | 120 | this.logger.error( |
| 117 | 121 | { err, repo: repoName, branch: bookmark.name }, |
| 118 | 122 | "Pages deployment failed" |
| 119 | 123 | |
| @@ -51,6 +51,11 @@ | ||
| 51 | 51 | delta_chunk_size = 1000000 |
| 52 | 52 | `; |
| 53 | 53 | |
| 54 | /** Flatten org/repo names to a single directory component (e.g. "letterpress-labs/site" → "letterpress-labs__site") */ | |
| 55 | function repoDirName(repoName: string): string { | |
| 56 | return repoName.replace(/\//g, "__"); | |
| 57 | } | |
| 58 | ||
| 54 | 59 | export class MononokeProvisioner { |
| 55 | 60 | constructor( |
| 56 | 61 | private configPath: string, |
| @@ -104,9 +109,10 @@ | ||
| 104 | 109 | */ |
| 105 | 110 | provisionRepo(repoName: string): number { |
| 106 | 111 | const repoId = this.getNextRepoId(); |
| 112 | const dirName = repoDirName(repoName); | |
| 107 | 113 | |
| 108 | const repoDefDir = join(this.configPath, "repo_definitions", repoName); | |
| 109 | const repoCfgDir = join(this.configPath, "repos", repoName); | |
| 114 | const repoDefDir = join(this.configPath, "repo_definitions", dirName); | |
| 115 | const repoCfgDir = join(this.configPath, "repos", dirName); | |
| 110 | 116 | |
| 111 | 117 | mkdirSync(repoDefDir, { recursive: true }); |
| 112 | 118 | mkdirSync(repoCfgDir, { recursive: true }); |
| @@ -116,7 +122,7 @@ | ||
| 116 | 122 | [ |
| 117 | 123 | `repo_id = ${repoId}`, |
| 118 | 124 | `repo_name = "${repoName}"`, |
| 119 | `repo_config = "${repoName}"`, | |
| 125 | `repo_config = "${dirName}"`, | |
| 120 | 126 | `enabled = true`, |
| 121 | 127 | `hipster_acl = "default"`, |
| 122 | 128 | "", |
| @@ -134,8 +140,9 @@ | ||
| 134 | 140 | * Does not clean up blobstore data (would need Mononoke internals). |
| 135 | 141 | */ |
| 136 | 142 | deprovisionRepo(repoName: string): void { |
| 137 | const repoDefDir = join(this.configPath, "repo_definitions", repoName); | |
| 138 | const repoCfgDir = join(this.configPath, "repos", repoName); | |
| 143 | const dirName = repoDirName(repoName); | |
| 144 | const repoDefDir = join(this.configPath, "repo_definitions", dirName); | |
| 145 | const repoCfgDir = join(this.configPath, "repos", dirName); | |
| 139 | 146 | |
| 140 | 147 | rmSync(repoDefDir, { recursive: true, force: true }); |
| 141 | 148 | rmSync(repoCfgDir, { recursive: true, force: true }); |
| 142 | 149 | |