@catladder/pipeline
Version:
Panter workflow for cloud CI/CD and DevOps
52 lines (48 loc) • 1.69 kB
text/typescript
import { getAllCacheConfigsFromConfig } from "../../build/cache/getAllCacheConfigsFromConfig";
import { getYarnInstall } from "../../build/node/yarn";
import { getRunnerImage } from "../../runner";
import type { ComponentContext } from "../../types/context";
import type { CatladderJob } from "../../types/jobs";
import { createDeployementJobs } from "../base";
import {
getDependencyTrackDeleteScript,
getDependencyTrackUploadScript,
} from "../sbom";
import { isOfDeployType } from "../types";
export const createCustomDeployJobs = (
context: ComponentContext,
): CatladderJob[] => {
const deployConfig = context.deploy?.config;
if (!isOfDeployType(deployConfig, "custom")) {
// should not happen
throw new Error("deploy config is not custom");
}
// FIXME: custom deploy currently assumes yarn-based project
const yarnInstall = getYarnInstall(context, {
noCustomPostInstall: true,
});
const result = createDeployementJobs(context, {
deploy: {
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
cache: getAllCacheConfigsFromConfig(context, deployConfig),
script: [
`cd ${context.build.dir}`,
...(deployConfig.requiresYarnInstall ? yarnInstall : []),
...deployConfig.script,
...getDependencyTrackUploadScript(context),
],
variables: {},
},
stop: deployConfig.stopScript
? {
image: deployConfig.jobImage ?? getRunnerImage("jobs-default"),
script: [
...deployConfig.stopScript,
...getDependencyTrackDeleteScript(context),
],
variables: {},
}
: undefined,
});
return result;
};