From bfd44aea841040eb5e60a7a3ca26ac928fa6169a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uro=C5=A1=20Marolt?= Date: Tue, 9 Jan 2024 13:44:10 +0100 Subject: [PATCH] testing docker action --- .github/actions/node/builder/index.js | 25 +++++++------------------ .github/actions/node/src/state.ts | 8 -------- .github/actions/node/src/steps.ts | 17 +++++++---------- 3 files changed, 14 insertions(+), 36 deletions(-) diff --git a/.github/actions/node/builder/index.js b/.github/actions/node/builder/index.js index 423941baa0..8ccea8850a 100644 --- a/.github/actions/node/builder/index.js +++ b/.github/actions/node/builder/index.js @@ -26291,20 +26291,12 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getImageTag = exports.setImageTag = exports.IS_POST = void 0; +exports.IS_POST = void 0; const core = __importStar(__nccwpck_require__(3949)); exports.IS_POST = !!process.env['STATE_isPost']; if (!exports.IS_POST) { core.saveState('isPost', 'true'); } -const setImageTag = (image, tag) => { - core.saveState(`imageTag.${image}`, tag); -}; -exports.setImageTag = setImageTag; -const getImageTag = (image) => { - return core.getState(`imageTag.${image}`); -}; -exports.getImageTag = getImageTag; /***/ }), @@ -26340,11 +26332,10 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.deployStep = exports.pushStep = exports.buildStep = void 0; const inputs_1 = __nccwpck_require__(2117); -const state_1 = __nccwpck_require__(5034); const types_1 = __nccwpck_require__(2106); const core = __importStar(__nccwpck_require__(3949)); const exec = __importStar(__nccwpck_require__(7912)); -const FAILED_IMAGE_TAG = 'FAILED_BUILD'; +const imageTagMap = new Map(); const buildStep = async () => { const inputs = await (0, inputs_1.getInputs)(); if (inputs[types_1.ActionStep.BUILD] === undefined) { @@ -26374,11 +26365,10 @@ const buildStep = async () => { }); if (exitCode !== 0) { core.error(`Failed to build image: ${image}:${actualTag}`); - (0, state_1.setImageTag)(image, FAILED_IMAGE_TAG); } else { alreadyBuilt.push(image); - (0, state_1.setImageTag)(image, actualTag); + imageTagMap.set(image, actualTag); } } }; @@ -26415,22 +26405,21 @@ const pushStep = async () => { core.info(`Skipping already pushed image: ${image}`); continue; } - const tag = (0, state_1.getImageTag)(image); - if (tag == FAILED_IMAGE_TAG) { - core.info(`Skipping failed image: ${image}`); + if (!imageTagMap.has(image)) { + core.warning(`No tag found for image: ${image} - image wasn't built successfully!`); continue; } + const tag = imageTagMap.get(image); core.info(`Pushing image: ${image}:${tag}!`); const exitCode = await exec.exec('bash', ['cli', 'push', image, tag], { cwd: './scripts', }); if (exitCode !== 0) { core.error(`Failed to push image: ${image}:${tag}`); - (0, state_1.setImageTag)(image, FAILED_IMAGE_TAG); + imageTagMap.delete(image); } else { alreadyPushed.push(image); - (0, state_1.setImageTag)(image, tag); } } }; diff --git a/.github/actions/node/src/state.ts b/.github/actions/node/src/state.ts index c03b4ddd7b..e6e888085c 100644 --- a/.github/actions/node/src/state.ts +++ b/.github/actions/node/src/state.ts @@ -5,11 +5,3 @@ export const IS_POST = !!process.env['STATE_isPost'] if (!IS_POST) { core.saveState('isPost', 'true') } - -export const setImageTag = (image: string, tag: string): void => { - core.saveState(`imageTag.${image}`, tag) -} - -export const getImageTag = (image: string): string | undefined => { - return core.getState(`imageTag.${image}`) -} diff --git a/.github/actions/node/src/steps.ts b/.github/actions/node/src/steps.ts index af9ce6e564..6803a4fb40 100644 --- a/.github/actions/node/src/steps.ts +++ b/.github/actions/node/src/steps.ts @@ -1,10 +1,9 @@ import { getInputs } from './inputs' -import { getImageTag, setImageTag } from './state' import { ActionStep } from './types' import * as core from '@actions/core' import * as exec from '@actions/exec' -const FAILED_IMAGE_TAG = 'FAILED_BUILD' +const imageTagMap = new Map() export const buildStep = async (): Promise => { const inputs = await getInputs() @@ -44,10 +43,9 @@ export const buildStep = async (): Promise => { if (exitCode !== 0) { core.error(`Failed to build image: ${image}:${actualTag}`) - setImageTag(image, FAILED_IMAGE_TAG) } else { alreadyBuilt.push(image) - setImageTag(image, actualTag) + imageTagMap.set(image, actualTag) } } } @@ -88,13 +86,13 @@ export const pushStep = async (): Promise => { continue } - const tag = getImageTag(image) - - if (tag == FAILED_IMAGE_TAG) { - core.info(`Skipping failed image: ${image}`) + if (!imageTagMap.has(image)) { + core.warning(`No tag found for image: ${image} - image wasn't built successfully!`) continue } + const tag = imageTagMap.get(image) + core.info(`Pushing image: ${image}:${tag}!`) const exitCode = await exec.exec('bash', ['cli', 'push', image, tag], { @@ -103,10 +101,9 @@ export const pushStep = async (): Promise => { if (exitCode !== 0) { core.error(`Failed to push image: ${image}:${tag}`) - setImageTag(image, FAILED_IMAGE_TAG) + imageTagMap.delete(image) } else { alreadyPushed.push(image) - setImageTag(image, tag) } } }