mirror of
https://github.com/redhat-actions/buildah-build.git
synced 2025-04-20 17:11:23 +00:00
Add summary message
Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
parent
85208924b2
commit
9f3925e198
5 changed files with 25 additions and 11 deletions
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -173,13 +173,16 @@ export class BuildahCli implements Buildah {
|
||||||
return this.execute(args);
|
return this.execute(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async tag(imageName: string, tags: string[]): Promise<CommandResult> {
|
async tag(imageName: string, tags: string[]): Promise<void> {
|
||||||
const args: string[] = [ "tag" ];
|
const args: string[] = [ "tag" ];
|
||||||
|
const builtImage = [];
|
||||||
for (const tag of tags) {
|
for (const tag of tags) {
|
||||||
args.push(getFullImageName(imageName, tag));
|
args.push(getFullImageName(imageName, tag));
|
||||||
|
builtImage.push(getFullImageName(imageName, tag));
|
||||||
}
|
}
|
||||||
core.info(`Tagging the built image with tags ${tags.toString()}`);
|
core.info(`Tagging the built image with tags ${tags.toString()}`);
|
||||||
return this.execute(args);
|
await this.execute(args);
|
||||||
|
core.info(`✅ Successfully built image${builtImage.length !== 1 ? "s" : ""} "${builtImage.join(", ")}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async manifestCreate(manifest: string): Promise<void> {
|
async manifestCreate(manifest: string): Promise<void> {
|
||||||
|
|
23
src/index.ts
23
src/index.ts
|
@ -10,7 +10,7 @@ import { Inputs, Outputs } from "./generated/inputs-outputs";
|
||||||
import { BuildahCli, BuildahConfigSettings } from "./buildah";
|
import { BuildahCli, BuildahConfigSettings } from "./buildah";
|
||||||
import {
|
import {
|
||||||
getArch, getPlatform, getContainerfiles, getInputList, splitByNewline,
|
getArch, getPlatform, getContainerfiles, getInputList, splitByNewline,
|
||||||
isFullImageName, getFullImageName, getTagSuffix,
|
isFullImageName, getFullImageName, removeIllegalCharacters,
|
||||||
} from "./utils";
|
} from "./utils";
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
|
@ -78,24 +78,35 @@ export async function run(): Promise<void> {
|
||||||
|
|
||||||
if ((archs.length > 0) || (platforms.length > 0)) {
|
if ((archs.length > 0) || (platforms.length > 0)) {
|
||||||
core.info(`Creating manifest with tag${tagsList.length !== 1 ? "s" : ""} "${tagsList.join(", ")}"`);
|
core.info(`Creating manifest with tag${tagsList.length !== 1 ? "s" : ""} "${tagsList.join(", ")}"`);
|
||||||
|
const builtImage = [];
|
||||||
|
const builtManifest = [];
|
||||||
for (const tag of tagsList) {
|
for (const tag of tagsList) {
|
||||||
const manifestName = getFullImageName(image, tag);
|
const manifestName = getFullImageName(image, tag);
|
||||||
await cli.manifestCreate(manifestName);
|
await cli.manifestCreate(manifestName);
|
||||||
|
builtManifest.push(manifestName);
|
||||||
|
|
||||||
for (const arch of archs) {
|
for (const arch of archs) {
|
||||||
const tagSuffix = getTagSuffix(arch);
|
const tagSuffix = removeIllegalCharacters(arch);
|
||||||
|
builtImage.push(`${newImage}-${tagSuffix}`);
|
||||||
await cli.manifestAdd(manifestName, `${newImage}-${tagSuffix}`);
|
await cli.manifestAdd(manifestName, `${newImage}-${tagSuffix}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const platform of platforms) {
|
for (const platform of platforms) {
|
||||||
const tagSuffix = getTagSuffix(platform);
|
const tagSuffix = removeIllegalCharacters(platform);
|
||||||
|
builtImage.push(`${newImage}-${tagSuffix}`);
|
||||||
await cli.manifestAdd(manifestName, `${newImage}-${tagSuffix}`);
|
await cli.manifestAdd(manifestName, `${newImage}-${tagSuffix}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.info(`✅ Successfully built image${builtImage.length !== 1 ? "s" : ""} "${builtImage.join(", ")}" `
|
||||||
|
+ `and manifest${builtManifest.length !== 1 ? "s" : ""} "${builtManifest.join(", ")}"`);
|
||||||
}
|
}
|
||||||
else if (tagsList.length > 1) {
|
else if (tagsList.length > 1) {
|
||||||
await cli.tag(image, tagsList);
|
await cli.tag(image, tagsList);
|
||||||
}
|
}
|
||||||
|
else if (tagsList.length === 1) {
|
||||||
|
core.info(`✅ Successfully built image "${getFullImageName(image, tagsList[0])}"`);
|
||||||
|
}
|
||||||
|
|
||||||
core.setOutput(Outputs.IMAGE, image);
|
core.setOutput(Outputs.IMAGE, image);
|
||||||
core.setOutput(Outputs.TAGS, tags);
|
core.setOutput(Outputs.TAGS, tags);
|
||||||
|
@ -131,7 +142,7 @@ async function doBuildUsingContainerFiles(
|
||||||
// therefore, appending arch/platform in the tag
|
// therefore, appending arch/platform in the tag
|
||||||
if (archs.length > 0 || platforms.length > 0) {
|
if (archs.length > 0 || platforms.length > 0) {
|
||||||
for (const arch of archs) {
|
for (const arch of archs) {
|
||||||
const tagSuffix = getTagSuffix(arch);
|
const tagSuffix = removeIllegalCharacters(arch);
|
||||||
await cli.buildUsingDocker(
|
await cli.buildUsingDocker(
|
||||||
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
|
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
|
||||||
useOCI, labels, layers, buildahBudExtraArgs, arch, undefined
|
useOCI, labels, layers, buildahBudExtraArgs, arch, undefined
|
||||||
|
@ -139,7 +150,7 @@ async function doBuildUsingContainerFiles(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const platform of platforms) {
|
for (const platform of platforms) {
|
||||||
const tagSuffix = getTagSuffix(platform);
|
const tagSuffix = removeIllegalCharacters(platform);
|
||||||
await cli.buildUsingDocker(
|
await cli.buildUsingDocker(
|
||||||
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
|
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
|
||||||
useOCI, labels, layers, buildahBudExtraArgs, undefined, platform
|
useOCI, labels, layers, buildahBudExtraArgs, undefined, platform
|
||||||
|
@ -171,7 +182,7 @@ async function doBuildFromScratch(
|
||||||
|
|
||||||
if (archs.length > 0) {
|
if (archs.length > 0) {
|
||||||
for (const arch of archs) {
|
for (const arch of archs) {
|
||||||
const tagSuffix = getTagSuffix(arch);
|
const tagSuffix = removeIllegalCharacters(arch);
|
||||||
const newImageConfig: BuildahConfigSettings = {
|
const newImageConfig: BuildahConfigSettings = {
|
||||||
entrypoint,
|
entrypoint,
|
||||||
port,
|
port,
|
||||||
|
|
|
@ -166,6 +166,6 @@ export function getFullImageName(image: string, tag: string): string {
|
||||||
return `${image}:${tag}`;
|
return `${image}:${tag}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTagSuffix(item: string): string {
|
export function removeIllegalCharacters(item: string): string {
|
||||||
return item.replace(/[^a-zA-Z0-9 ]/g, "");
|
return item.replace(/[^a-zA-Z0-9 ]/g, "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue