#!/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();