Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for annotations as an action input. #135

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -2,4 +2,7 @@ module.exports = {
extends: [
"@redhat-actions/eslint-config",
],
};
ignorePatterns: [
"src/generated/*"
]
};
8 changes: 7 additions & 1 deletion .github/workflows/docker_metadata_action.yml
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@ jobs:
layers: false
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
annotations: ${{ steps.docker-metadata.outputs.annotations }}
containerfiles: |
./Containerfile
extra-args: |
@@ -83,6 +84,8 @@ jobs:
set -x
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Labels."org.opencontainers.image.title"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Labels."org.opencontainers.image.description"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Annotations."org.opencontainers.image.title"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Annotations."org.opencontainers.image.description"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.Docker.config.Labels."org.opencontainers.image.title"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.Docker.config.Labels."org.opencontainers.image.description"'
@@ -107,7 +110,7 @@ jobs:

- name: Docker Metadata
id: docker-metadata
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_NAME }}
@@ -154,6 +157,7 @@ jobs:
with:
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
annotations: ${{ steps.docker-metadata.outputs.annotations }}
base-image: 'registry.access.redhat.com/openjdk/openjdk-11-rhel7'
# To avoid hardcoding a particular version of the binary.
content: |
@@ -181,5 +185,7 @@ jobs:
set -x
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Labels."org.opencontainers.image.title"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Labels."org.opencontainers.image.description"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Annotations."org.opencontainers.image.title"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.OCIv1.config.Annotations."org.opencontainers.image.description"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.Docker.config.Labels."org.opencontainers.image.title"'
buildah inspect ${{ steps.build_image.outputs.image-with-tag }} | jq '.Docker.config.Labels."org.opencontainers.image.description"'
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -15,6 +15,9 @@ inputs:
labels:
description: 'The labels of the image to build. Seperate by newline. For example, "io.containers.capabilities=sys_admin,mknod".'
required: false
annotations:
description: 'The annotations of the image to build. Seperate by newline. For example, "org.opencontainers.image.version=1.5.6". Only supported by OCI images.'
required: false
base-image:
description: 'The base image to use to create a new container image'
required: false
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/buildah.ts
Original file line number Diff line number Diff line change
@@ -16,12 +16,13 @@ export interface BuildahConfigSettings {
workingdir?: string;
arch?: string;
labels?: string[];
annotations?: string[];
}

interface Buildah {
buildUsingDocker(
image: string, context: string, containerFiles: string[], buildArgs: string[],
useOCI: boolean, labels: string[], layers: string,
useOCI: boolean, labels: string[], annotations: string[], layers: string,
extraArgs: string[], tlsVerify: boolean, arch?: string, platform?: string,
): Promise<CommandResult>;
from(baseImage: string, tlsVerify: boolean, extraArgs: string[]): Promise<CommandResult>;
@@ -72,6 +73,7 @@ export class BuildahCli implements Buildah {
buildArgs: string[],
useOCI: boolean,
labels: string[],
annotations: string[],
layers: string,
extraArgs: string[],
tlsVerify: boolean,
@@ -95,6 +97,12 @@ export class BuildahCli implements Buildah {
args.push("--label");
args.push(label);
});
if (useOCI) {
annotations.forEach((annotation) => {
args.push("--annotation");
args.push(annotation);
});
}
buildArgs.forEach((buildArg) => {
args.push("--build-arg");
args.push(buildArg);
6 changes: 6 additions & 0 deletions src/generated/inputs-outputs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// This file was auto-generated by action-io-generator. Do not edit by hand!
export enum Inputs {
/**
* The annotations of the image to build. Seperate by newline. For example, "org.opencontainers.image.version=1.5.6". Only supported by OCI images.
* Required: false
* Default: None.
*/
ANNOTATIONS = "annotations",
/**
* Label the image with this ARCH, instead of defaulting to the host architecture
* Required: false
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@ export async function run(): Promise<void> {
const tagsList: string[] = tags.trim().split(/\s+/);
const labels = core.getInput(Inputs.LABELS);
const labelsList: string[] = labels ? splitByNewline(labels) : [];
const annotations = core.getInput(Inputs.ANNOTATIONS);
const annotationList: string[] = annotations ? splitByNewline(annotations) : [];

const normalizedTagsList: string[] = [];
let isNormalized = false;
@@ -96,6 +98,7 @@ export async function run(): Promise<void> {
archs,
platforms,
labelsList,
annotationList,
buildahExtraArgs
));
}
@@ -152,6 +155,7 @@ async function doBuildUsingContainerFiles(
archs: string[],
platforms: string[],
labels: string[],
annotations: string[],
extraArgs: string[]
): Promise<string[]> {
if (containerFiles.length === 1) {
@@ -185,6 +189,7 @@ async function doBuildUsingContainerFiles(
buildArgs,
useOCI,
labels,
annotations,
layers,
extraArgs,
tlsVerify,
@@ -205,6 +210,7 @@ async function doBuildUsingContainerFiles(
buildArgs,
useOCI,
labels,
annotations,
layers,
extraArgs,
tlsVerify,
@@ -223,6 +229,7 @@ async function doBuildUsingContainerFiles(
buildArgs,
useOCI,
labels,
annotations,
layers,
extraArgs,
tlsVerify,
@@ -239,6 +246,7 @@ async function doBuildUsingContainerFiles(
buildArgs,
useOCI,
labels,
annotations,
layers,
extraArgs,
tlsVerify