| @@ -237,7 +237,7 @@ | ||
| 237 | 237 | return reply.code(503).send({ error: "Canopy not enabled" }); |
| 238 | 238 | } |
| 239 | 239 | const { owner, repo } = request.params; |
| 240 | const { ref } = (request.body as any) ?? {}; | |
| 240 | const { ref, pipeline } = (request.body as any) ?? {}; | |
| 241 | 241 | const branch = ref || "main"; |
| 242 | 242 | const bridgeUrl = |
| 243 | 243 | process.env.GROVE_BRIDGE_URL ?? "http://localhost:3100"; |
| @@ -255,7 +255,7 @@ | ||
| 255 | 255 | branch, |
| 256 | 256 | oldCommitId: "", |
| 257 | 257 | newCommitId: commit_id, |
| 258 | }); | |
| 258 | }, pipeline); | |
| 259 | 259 | } catch { |
| 260 | 260 | return reply.code(500).send({ error: "Failed to queue pipeline runs" }); |
| 261 | 261 | } |
| 262 | 262 | |
| @@ -124,7 +124,7 @@ | ||
| 124 | 124 | return Number(result.lastInsertRowid); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | async onPush(event: PushEvent): Promise<void> { | |
| 127 | async onPush(event: PushEvent, pipelineFilter?: string): Promise<void> { | |
| 128 | 128 | const repoId = this.ensureRepo(event.repo); |
| 129 | 129 | if (!repoId) return; |
| 130 | 130 | |
| @@ -145,6 +145,7 @@ | ||
| 145 | 145 | |
| 146 | 146 | const matched = configs |
| 147 | 147 | .filter(({ file, config }) => this.matchesTrigger(config, file, event.branch, changedFiles)) |
| 148 | .filter(({ config }) => !pipelineFilter || config.name === pipelineFilter) | |
| 148 | 149 | .sort((a, b) => (a.config.order ?? 0) - (b.config.order ?? 0)); |
| 149 | 150 | if (matched.length === 0) return; |
| 150 | 151 | |
| 151 | 152 | |
| @@ -8,14 +8,18 @@ | ||
| 8 | 8 | const refIdx = args.indexOf("--ref"); |
| 9 | 9 | const ref = refIdx !== -1 ? args[refIdx + 1] : undefined; |
| 10 | 10 | |
| 11 | const pipelineIdx = args.indexOf("--pipeline"); | |
| 12 | const pipeline = pipelineIdx !== -1 ? args[pipelineIdx + 1] : undefined; | |
| 13 | ||
| 11 | 14 | const s = spinner(); |
| 12 | 15 | s.start("Triggering pipelines"); |
| 13 | 16 | const result = await hubRequest<{ triggered: boolean; branch: string; commit_id: string }>( |
| 14 | 17 | `/api/repos/${slug}/canopy/trigger`, |
| 15 | 18 | { |
| 16 | 19 | method: "POST", |
| 17 | body: JSON.stringify({ ref }), | |
| 20 | body: JSON.stringify({ ref, pipeline }), | |
| 18 | 21 | } |
| 19 | 22 | ); |
| 20 | s.stop(`Triggered pipelines on ${result.branch} (${result.commit_id.slice(0, 12)})`); | |
| 23 | const label = pipeline ? `"${pipeline}"` : "pipelines"; | |
| 24 | s.stop(`Triggered ${label} on ${result.branch} (${result.commit_id.slice(0, 12)})`); | |
| 21 | 25 | } |
| 22 | 26 | |