diff options
author | houston[bot] <astrobot-houston@users.noreply.github.com> | 2025-08-10 16:30:08 -0700 |
---|---|---|
committer | Elizabeth Hunt <me@liz.coffee> | 2025-08-11 18:30:29 -0700 |
commit | 941cd2cb0ff2b9f40c424f3b36d59064e1e8fdb9 (patch) | |
tree | 43a1306ce3d6419ffbe042c328dbf9e372691198 /.ci/ci.ts | |
download | coffee-941cd2cb0ff2b9f40c424f3b36d59064e1e8fdb9.tar.gz coffee-941cd2cb0ff2b9f40c424f3b36d59064e1e8fdb9.zip |
Initial commit
Diffstat (limited to '.ci/ci.ts')
-rw-r--r-- | .ci/ci.ts | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/.ci/ci.ts b/.ci/ci.ts new file mode 100644 index 0000000..4e653c7 --- /dev/null +++ b/.ci/ci.ts @@ -0,0 +1,74 @@ +#!/usr/bin/env node + +import { + AnsiblePlaybookJob, + BuildDockerImageJob, + DefaultGitHookPipelineBuilder, + FetchCodeJob, + Job, +} from '@emprespresso/ci_model'; +import { join } from 'path'; + +const REGISTRY = 'oci.liz.coffee'; +const NAMESPACE = 'emprespresso'; +const IMG = 'coffee'; +const REMOTE = 'ssh://src.liz.coffee:2222'; + +const getPipeline = () => { + const gitHookPipeline = new DefaultGitHookPipelineBuilder(); + const branch = gitHookPipeline.getBranch(); + if (!branch) return gitHookPipeline.build(); + + const commonBuildArgs = { + context: gitHookPipeline.getSourceDestination(), + registry: REGISTRY, + namespace: NAMESPACE, + imageTag: branch, + }; + + const build: BuildDockerImageJob = { + type: 'build_docker_image.js', + arguments: { + ...commonBuildArgs, + repository: IMG, + buildTarget: IMG, + dockerfile: 'Dockerfile', + }, + }; + gitHookPipeline.addStage({ + parallelJobs: [build], + }); + + const isRelease = branch === 'release'; + if (!isRelease) { + return gitHookPipeline.build(); + } + + const fetchAnsibleCode: FetchCodeJob = { + type: 'fetch_code', + arguments: { + remoteUrl: `${REMOTE}/infra`, + checkout: 'main', + path: 'infra', + }, + }; + const thenDeploy: AnsiblePlaybookJob = { + type: 'ansible_playbook.js', + arguments: { + path: 'infra', + playbooks: 'playbooks/coffee.yml', + }, + }; + [fetchAnsibleCode, thenDeploy].forEach((deploymentStage) => + gitHookPipeline.addStage({ parallelJobs: [deploymentStage] }), + ); + + return gitHookPipeline.build(); +}; + +const main = () => { + const data = getPipeline().serialize(); + process.stdout.write(data); +}; + +main(); |