Add io generator and CI checks (#25)

Signed-off-by: divyansh42 <diagrawa@redhat.com>
This commit is contained in:
Divyanshu Agrawal 2021-02-08 21:54:18 +05:30 committed by GitHub
parent 88e0085544
commit 20a8e62ce0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 189 additions and 6660 deletions

View file

@ -0,0 +1,90 @@
// This file was auto-generated by action-io-generator. Do not edit by hand!
export enum Inputs {
/**
* The base image to use to create a new container image
* Required: true
* Default: None.
*/
BASE_IMAGE = "base-image",
/**
* List of --build-args to pass to buildah
* Required: false
* Default: None.
*/
BUILD_ARGS = "build-args",
/**
* List of files/directories to copy inside the base image
* Required: false
* Default: None.
*/
CONTENT = "content",
/**
* Path of the directory to use as context (default: .)
* Required: false
* Default: "."
*/
CONTEXT = "context",
/**
* List of Dockerfile paths (eg: ./Dockerfile)
* Required: false
* Default: None.
*/
DOCKERFILES = "dockerfiles",
/**
* The entry point to set for containers based on image
* Required: false
* Default: None.
*/
ENTRYPOINT = "entrypoint",
/**
* List of environment variables to be set when running containers based on image
* Required: false
* Default: None.
*/
ENVS = "envs",
/**
* The name (reference) of the image to build
* Required: true
* Default: None.
*/
IMAGE = "image",
/**
* Set to true to build using the OCI image format instead of the Docker image format
* Required: false
* Default: "false"
*/
OCI = "oci",
/**
* The port to expose when running containers based on image
* Required: false
* Default: None.
*/
PORT = "port",
/**
* The tags of the image to build. For multiple tags, seperate by a space. For example, "latest v1".
* Required: false
* Default: "latest"
*/
TAGS = "tags",
/**
* The working directory to use within the container
* Required: false
* Default: None.
*/
WORKDIR = "workdir",
}
export enum Outputs {
/**
* Name of the image built
* Required: false
* Default: None.
*/
IMAGE = "image",
/**
* List of the tags that were created, separated by spaces
* Required: false
* Default: None.
*/
TAGS = "tags",
}

View file

@ -1,6 +1,7 @@
import * as core from "@actions/core";
import * as io from "@actions/io";
import * as path from "path";
import { Inputs, Outputs } from "./generated/inputs-outputs";
import { BuildahCli, BuildahConfigSettings } from "./buildah";
export async function run(): Promise<void> {
@ -13,12 +14,12 @@ export async function run(): Promise<void> {
const cli: BuildahCli = new BuildahCli(buildahPath);
const workspace = process.env.GITHUB_WORKSPACE || process.cwd();
const dockerFiles = getInputList("dockerfiles");
const image = core.getInput("image", { required: true });
const tags = core.getInput("tags") || "latest";
const dockerFiles = getInputList(Inputs.DOCKERFILES);
const image = core.getInput(Inputs.IMAGE, { required: true });
const tags = core.getInput(Inputs.TAGS) || "latest";
const tagsList: string[] = tags.split(" ");
const newImage = `${image}:${tagsList[0]}`;
const useOCI = core.getInput("oci") === "true";
const useOCI = core.getInput(Inputs.OCI) === "true";
if (dockerFiles.length !== 0) {
await doBuildUsingDockerFiles(cli, newImage, workspace, dockerFiles, useOCI);
@ -30,8 +31,8 @@ export async function run(): Promise<void> {
if (tagsList.length > 1) {
await cli.tag(image, tagsList);
}
core.setOutput("image", image);
core.setOutput("tags", tags);
core.setOutput(Outputs.IMAGE, image);
core.setOutput(Outputs.TAGS, tags);
}
async function doBuildUsingDockerFiles(
@ -44,8 +45,8 @@ async function doBuildUsingDockerFiles(
core.info(`Performing build from ${dockerFiles.length} Dockerfiles`);
}
const context = path.join(workspace, core.getInput("context"));
const buildArgs = getInputList("build-args");
const context = path.join(workspace, core.getInput(Inputs.CONTEXT));
const buildArgs = getInputList(Inputs.BUILD_ARGS);
const dockerFileAbsPaths = dockerFiles.map((file) => path.join(workspace, file));
await cli.buildUsingDocker(newImage, context, dockerFileAbsPaths, buildArgs, useOCI);
}
@ -55,12 +56,12 @@ async function doBuildFromScratch(
): Promise<void> {
core.info(`Performing build from scratch`);
const baseImage = core.getInput("base-image", { required: true });
const content = getInputList("content");
const entrypoint = getInputList("entrypoint");
const port = core.getInput("port");
const workingDir = core.getInput("workdir");
const envs = getInputList("envs");
const baseImage = core.getInput(Inputs.BASE_IMAGE, { required: true });
const content = getInputList(Inputs.CONTENT);
const entrypoint = getInputList(Inputs.ENTRYPOINT);
const port = core.getInput(Inputs.PORT);
const workingDir = core.getInput(Inputs.WORKDIR);
const envs = getInputList(Inputs.ENVS);
const container = await cli.from(baseImage);
const containerId = container.output.replace("\n", "");