Skip to content

Commit

Permalink
builtImages
Browse files Browse the repository at this point in the history
  • Loading branch information
identw committed Dec 8, 2023
1 parent 6a3fe53 commit 5c563d9
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions js-action/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ async function main() {
// Build images
if (operation == 'build' || operation == 'build-and-push') {
let copyFiles = [];
let images = {};
let builtImages = {};
createDir('copy-files');

for (const image of buildOpts) {

const imageTag = `${registry}/${repoName}/${image.name}:${tag}`;
console.log(`Build image: ${imageTag}`);
images[image] = imageTag;
builtImages[image] = imageTag;

let args = '';
if ('args' in image) {
Expand Down Expand Up @@ -76,13 +76,13 @@ async function main() {
}
}

core.setOutput('built-images', JSON.stringify(images));
core.setOutput('built-images', JSON.stringify(builtImages));
core.setOutput('copy-files', JSON.stringify(copyFiles));
}

// push
if (operation == 'push' || operation == 'build-and-push') {
let images = [];
let pushImages = [];

// Сначала выполняем prePush для временных тегов, это нужно чтобы затем как можно быстрее и параллельно запушить итоговые теги (слои уже будут в registry и это пройдет быстрее). Это полезно для argocd-image-updater и flux image reflector, это повысит вероятность, что новый тег будет обнаружен в образах за один проход

Expand All @@ -94,7 +94,7 @@ async function main() {

runCommand(`docker tag ${imageTag} ${imagePrePushTag}`);
runCommand(`docker push ${imagePrePushTag}`);
images.push(imageTag);
pushImages.push(imageTag);
prePushImages.push({
registry: `https://${registry}`,
repo: `${repoName}/${image.name}`,
Expand All @@ -106,7 +106,7 @@ async function main() {
// а здесь лишь запуск тредов
const workerScript = __filename;

images.forEach(image => {
pushImages.forEach(image => {
const worker = new Worker(workerScript, { workerData: { image } });
worker.on('error', (error) => {
console.error(`Worker for image ${image} encountered an error: ${error.message}`);
Expand All @@ -120,11 +120,11 @@ async function main() {
});
});

core.setOutput('pushed-images', JSON.stringify(images));
console.log('\x1b[34m%s\x1b[0m',`built images: ${JSON.stringify(images, null, 2)}`);
core.setOutput('pushed-images', JSON.stringify(pushImages));
console.log('\x1b[34m%s\x1b[0m',`built images: ${JSON.stringify(pushImages, null, 2)}`);
await core.summary
.addHeading('Built images')
.addCodeBlock(JSON.stringify(images, null, 2), "json")
.addCodeBlock(JSON.stringify(pushImages, null, 2), "json")
.write()
}

Expand Down

0 comments on commit 5c563d9

Please sign in to comment.