UNPKG

envilder

Version:

A CLI that securely centralizes your environment variables from AWS SSM as a single source of truth

62 lines 3.15 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import 'reflect-metadata'; import { DispatchActionCommand } from '../../envilder/application/dispatch/DispatchActionCommand.js'; import { TYPES } from '../../envilder/types.js'; import { Startup } from './Startup.js'; let serviceProvider; /** * Reads GitHub Actions inputs from environment variables. * GitHub Actions passes inputs as INPUT_<NAME> environment variables. */ function readInputs() { const mapFile = process.env.INPUT_MAP_FILE; const envFile = process.env.INPUT_ENV_FILE; return { map: mapFile, envfile: envFile, // GitHub Action only supports pull mode push: false, }; } function executeCommand(options) { return __awaiter(this, void 0, void 0, function* () { const commandHandler = serviceProvider.get(TYPES.DispatchActionCommandHandler); const command = DispatchActionCommand.fromCliOptions(options); yield commandHandler.handleCommand(command); }); } export function main() { return __awaiter(this, void 0, void 0, function* () { const logger = serviceProvider === null || serviceProvider === void 0 ? void 0 : serviceProvider.get(TYPES.ILogger); try { const options = readInputs(); // Validate required inputs if (!options.map || !options.envfile) { throw new Error('🚨 Missing required inputs! Please provide map-file and env-file.'); } logger === null || logger === void 0 ? void 0 : logger.info('🔑 Envilder GitHub Action - Starting secret pull...'); logger === null || logger === void 0 ? void 0 : logger.info(`📋 Map file: ${options.map}`); logger === null || logger === void 0 ? void 0 : logger.info(`📄 Env file: ${options.envfile}`); yield executeCommand(options); logger === null || logger === void 0 ? void 0 : logger.info('✅ Secrets pulled successfully!'); } catch (error) { logger === null || logger === void 0 ? void 0 : logger.error('🚨 Uh-oh! Looks like Mario fell into the wrong pipe! 🍄💥'); logger === null || logger === void 0 ? void 0 : logger.error(error instanceof Error ? error.message : String(error)); throw error; } }); } // Initialize the service provider const startup = Startup.build(); startup.configureServices().configureInfrastructure(); serviceProvider = startup.create(); //# sourceMappingURL=Gha.js.map