UNPKG

@catladder/pipeline

Version:

Panter workflow for cloud CI/CD and DevOps

74 lines (73 loc) 2.4 kB
"use strict"; 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.createAgentEventJob = void 0; var prompts_1 = require("./prompts"); var shared_1 = require("./shared"); var utils_1 = require("./utils"); var createAgentEventJob = function (context) { var baseJob = (0, shared_1.createBaseAgentJob)(context); // unfortunatly, we need to manage both, because the "@mention"-feature only works with the username var agentUserId = (0, utils_1.getAgentUserId)(context); var agentUserName = (0, utils_1.getAgentUserName)(context); return __assign(__assign({ interruptible: false }, baseJob), { variables: __assign({}, baseJob.variables), name: context.name + "-agent-event", rules: [{ if: "$CI_PIPELINE_SOURCE == \"trigger\" && ($ASSIGNEE_USER_ID == ".concat(agentUserId, " || $OBJECT_DESCRIPTION =~ /@").concat(agentUserName, "/)"), when: "always" }, { when: "never" }], script: __spreadArray(__spreadArray([], __read(shared_1.baseSetupScript), false), __read((0, shared_1.callClaude)({ prompt: (0, prompts_1.getEventPrompt)({ agentUserName: agentUserName }) })), false) }); }; exports.createAgentEventJob = createAgentEventJob;