Skip to content

Commit

Permalink
testing docker action
Browse files Browse the repository at this point in the history
  • Loading branch information
Uroš Marolt committed Jan 9, 2024
1 parent 0001d28 commit bfd44ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 36 deletions.
25 changes: 7 additions & 18 deletions .github/actions/node/builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/***/ }),
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
};
Expand Down Expand Up @@ -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);
}
}
};
Expand Down
8 changes: 0 additions & 8 deletions .github/actions/node/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
17 changes: 7 additions & 10 deletions .github/actions/node/src/steps.ts
Original file line number Diff line number Diff line change
@@ -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<string, string>()

export const buildStep = async (): Promise<void> => {
const inputs = await getInputs()
Expand Down Expand Up @@ -44,10 +43,9 @@ export const buildStep = async (): Promise<void> => {

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)
}
}
}
Expand Down Expand Up @@ -88,13 +86,13 @@ export const pushStep = async (): Promise<void> => {
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], {
Expand All @@ -103,10 +101,9 @@ export const pushStep = async (): Promise<void> => {

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)
}
}
}
Expand Down

0 comments on commit bfd44ae

Please sign in to comment.