Add summary message

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
divyansh42 2021-11-11 10:44:52 +05:30
parent 85208924b2
commit 9f3925e198
5 changed files with 25 additions and 11 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -173,13 +173,16 @@ export class BuildahCli implements Buildah {
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 builtImage = [];
for (const tag of tags) {
args.push(getFullImageName(imageName, tag));
builtImage.push(getFullImageName(imageName, tag));
}
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> {

View file

@ -10,7 +10,7 @@ import { Inputs, Outputs } from "./generated/inputs-outputs";
import { BuildahCli, BuildahConfigSettings } from "./buildah";
import {
getArch, getPlatform, getContainerfiles, getInputList, splitByNewline,
isFullImageName, getFullImageName, getTagSuffix,
isFullImageName, getFullImageName, removeIllegalCharacters,
} from "./utils";
export async function run(): Promise<void> {
@ -78,24 +78,35 @@ export async function run(): Promise<void> {
if ((archs.length > 0) || (platforms.length > 0)) {
core.info(`Creating manifest with tag${tagsList.length !== 1 ? "s" : ""} "${tagsList.join(", ")}"`);
const builtImage = [];
const builtManifest = [];
for (const tag of tagsList) {
const manifestName = getFullImageName(image, tag);
await cli.manifestCreate(manifestName);
builtManifest.push(manifestName);
for (const arch of archs) {
const tagSuffix = getTagSuffix(arch);
const tagSuffix = removeIllegalCharacters(arch);
builtImage.push(`${newImage}-${tagSuffix}`);
await cli.manifestAdd(manifestName, `${newImage}-${tagSuffix}`);
}
for (const platform of platforms) {
const tagSuffix = getTagSuffix(platform);
const tagSuffix = removeIllegalCharacters(platform);
builtImage.push(`${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) {
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.TAGS, tags);
@ -131,7 +142,7 @@ async function doBuildUsingContainerFiles(
// therefore, appending arch/platform in the tag
if (archs.length > 0 || platforms.length > 0) {
for (const arch of archs) {
const tagSuffix = getTagSuffix(arch);
const tagSuffix = removeIllegalCharacters(arch);
await cli.buildUsingDocker(
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
useOCI, labels, layers, buildahBudExtraArgs, arch, undefined
@ -139,7 +150,7 @@ async function doBuildUsingContainerFiles(
}
for (const platform of platforms) {
const tagSuffix = getTagSuffix(platform);
const tagSuffix = removeIllegalCharacters(platform);
await cli.buildUsingDocker(
`${newImage}-${tagSuffix}`, context, containerFileAbsPaths, buildArgs,
useOCI, labels, layers, buildahBudExtraArgs, undefined, platform
@ -171,7 +182,7 @@ async function doBuildFromScratch(
if (archs.length > 0) {
for (const arch of archs) {
const tagSuffix = getTagSuffix(arch);
const tagSuffix = removeIllegalCharacters(arch);
const newImageConfig: BuildahConfigSettings = {
entrypoint,
port,

View file

@ -166,6 +166,6 @@ export function getFullImageName(image: string, tag: string): string {
return `${image}:${tag}`;
}
export function getTagSuffix(item: string): string {
export function removeIllegalCharacters(item: string): string {
return item.replace(/[^a-zA-Z0-9 ]/g, "");
}