UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

77 lines 2.92 kB
"use strict"; /* * Copyright © 2020 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.action = void 0; const _ = require("lodash"); const container_1 = require("./container"); function action(registration) { const containerRegistration = { containers: [{ name: registration.name, image: registration.image, secrets: registration.secrets, env: convertParameters(registration.parameters), }], input: registration.input, output: registration.output, callback: async (r, p, g, e, c) => { var _a, _b; const env = [{ name: "GITHUB_WORKFLOW", value: registration.name, }, { name: "GITHUB_ACTION", value: e.goalSetId, }, { name: "GITHUB_ACTIONS", value: "true", }, { name: "GITHUB_ACTOR", value: "Atomist", }, { name: "GITHUB_REPOSITORY", value: `${e.repo.owner}/${e.repo.name}`, }, { name: "GITHUB_EVENT_NAME", value: "push", }, { name: "GITHUB_WORKSPACE", value: container_1.ContainerProjectHome, }, { name: "GITHUB_SHA", value: e.sha, }]; r.containers[0].env = [ ...(r.containers[0].env || []), ...env, ]; if (!!((_b = (_a = r.containers[0]) === null || _a === void 0 ? void 0 : _a.secrets) === null || _b === void 0 ? void 0 : _b.env)) { r.containers[0].secrets.env = r.containers[0].secrets.env.map(ev => ({ name: `INPUT_${ev.name.toUpperCase()}`, value: ev.value, })); } return r; }, }; return container_1.container(registration.name, containerRegistration); } exports.action = action; function convertParameters(parameters) { return _.map(parameters || {}, (v, k) => ({ name: `INPUT_${k.toUpperCase()}`, value: v })); } //# sourceMappingURL=action.js.map