@catladder/pipeline
Version:
Panter workflow for cloud CI/CD and DevOps
90 lines (89 loc) • 3.82 kB
JavaScript
;
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = this && this.__read || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o),
r,
ar = [],
e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
} catch (error) {
e = {
error: error
};
} finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
} finally {
if (e) throw e.error;
}
}
return ar;
};
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createRailsBuildJobs = void 0;
var __1 = require("../..");
var base_1 = require("../base");
var docker_1 = require("../docker");
var types_1 = require("../types");
var createRailsBuildJobs = function (context) {
var _a, _b, _c;
var buildConfig = context.build.config;
if (!(0, types_1.isOfBuildType)(buildConfig, "rails")) {
// should not happen
throw new Error("build type is not rails");
}
// if its not a standalone build, we don't need to run tests
if (!(0, __1.componentContextIsStandaloneBuild)(context)) {
throw new Error("workspace builds are not supported for rails apps");
}
if ((0, docker_1.hasDockerfile)(context)) {
return (0, base_1.createComponentBuildJobs)(context, {
appBuild: undefined,
dockerBuild: {
script: (0, docker_1.getDockerBuildDefaultScript)(context),
variables: {}
}
});
}
var cnbConf = buildConfig.cnbBuilder;
var packEnvArgs = Object.entries((_a = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.buildVars) !== null && _a !== void 0 ? _a : {}).map(function (_a) {
var _b = __read(_a, 2),
k = _b[0],
v = _b[1];
return "--env '".concat(k).concat(v ? "=".concat(v) : "", "'");
}).join(" ");
return (0, base_1.createComponentBuildJobs)(context, {
appBuild: undefined,
dockerBuild: {
variables: __assign({}, context.environment.jobOnlyVars.build.envVars),
// custom script
script: __spreadArray(__spreadArray([], __read((0, docker_1.gitlabDockerLogin)(context)), false), ["cd ".concat(context.build.dir), "wget --output-document=- https://github.com/buildpacks/pack/releases/download/v".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "/pack-v").concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packVersion, "-linux.tgz | tar -zx --directory /usr/local/bin pack"), "chmod +x /usr/local/bin/pack",
// replace private git ssh gem sources with https to make bundler with credentials via env var work
"sed --in-place 's|git@\\([^:]*\\):|https://\\1/|g' Gemfile Gemfile.lock", "pack build \"$DOCKER_IMAGE:$DOCKER_IMAGE_TAG\" --builder '".concat(cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.image, "' --publish --cache-image \"$DOCKER_CACHE_IMAGE\" ").concat(packEnvArgs, " ").concat((_c = (_b = cnbConf === null || cnbConf === void 0 ? void 0 : cnbConf.packExtraArgs) === null || _b === void 0 ? void 0 : _b.join(" ")) !== null && _c !== void 0 ? _c : "")], false)
}
});
};
exports.createRailsBuildJobs = createRailsBuildJobs;