1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/usr/bin/env node
import { BuildDockerImageJob, CoolifyWebhookJob, DefaultGitHookPipelineBuilder } from "@emprespresso/ci_model";
const REGISTRY = "img.liz.coffee";
const NAMESPACE = "emprespresso";
const IMG = "rookery";
/** Coolify deploy hooks: `release` is the public download site, `main` is the beta one. Other branches only build. */
const getReleaseDeployment = (branch: string) => {
switch (branch) {
case "release":
return "https://plane.liz.coffee/api/v1/deploy?uuid=vzhqmprh2hqbjjcqrzxwkzww&force=false";
case "main":
return "https://plane.liz.coffee/api/v1/deploy?uuid=0hgnqywenjjcfltl6hoxmro0&force=false";
default:
return null;
}
};
/**
* Every push builds the Dockerfile's `rookery` target: the test suite runs, the apps are built, and the
* result is a small web server with a download page (a failing test fails the image build). Pushes to
* `main` and `release` then tell Coolify to pull the new image.
*/
const getPipeline = () => {
const gitHookPipeline = new DefaultGitHookPipelineBuilder();
const branch = gitHookPipeline.getBranch();
if (!branch) return gitHookPipeline.build();
const build: BuildDockerImageJob = {
type: "build_docker_image.js",
arguments: {
context: gitHookPipeline.getSourceDestination(),
registry: REGISTRY,
namespace: NAMESPACE,
repository: IMG,
imageTag: branch,
commit: gitHookPipeline.getRev(),
buildTarget: IMG,
dockerfile: "Dockerfile",
},
};
gitHookPipeline.addStage({ parallelJobs: [build] });
const webhookUrl = getReleaseDeployment(branch);
if (webhookUrl === null) return gitHookPipeline.build();
const deploy: CoolifyWebhookJob = {
type: "coolify_webhook.js",
arguments: { webhookUrl },
};
gitHookPipeline.addStage({ parallelJobs: [deploy] });
return gitHookPipeline.build();
};
const main = () => {
const data = getPipeline().serialize();
process.stdout.write(data);
};
main();
|