From 99beb78b03f62c0bcd9ca4282ff69f2fe2bde250 Mon Sep 17 00:00:00 2001 From: omer nitzan Date: Tue, 29 Aug 2023 20:18:01 +0300 Subject: [PATCH] fix: add new flag --- README.md | 2 +- action.yml | 6 ++++++ src/generated/inputs-outputs.ts | 6 ++++++ src/index.ts | 4 +++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 04b6ab2..c8de337 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ After building your image, use [push-to-registry](https://github.com/redhat-acti | workdir | The working directory to use within the container. | None | extra-args | Extra args to be passed to `buildah from`. Separate arguments by newline. Do not use quotes. | None | tls-verify | Require HTTPS and verify certificates when accessing the registry. Set to `false` to skip the verification. This will be used with `buildah from` command. | `true` - +| self-hosted-runner-root | If you are running on self hosted runner, you can set this so it will add "sudo" to every buildah command if you dont want to run rootless |`false` ### Image and Tags Inputs The `image` and `tags` inputs can be provided in one of two forms. diff --git a/action.yml b/action.yml index 25e62fe..1c571d0 100644 --- a/action.yml +++ b/action.yml @@ -82,6 +82,12 @@ inputs: Require HTTPS and verify certificates when accessing the registry. Defaults to true. required: false default: 'true' + self-hosted-runner-root: + description: | + If you are running on self hosted runner, you can set this so it will add "sudo" to every + buildah command if you dont want to run rootless. Defaults to false + required: false + default: 'false' outputs: image: description: 'Name of the image built' diff --git a/src/generated/inputs-outputs.ts b/src/generated/inputs-outputs.ts index 14db811..266bd73 100644 --- a/src/generated/inputs-outputs.ts +++ b/src/generated/inputs-outputs.ts @@ -130,6 +130,12 @@ export enum Inputs { * Default: None. */ WORKDIR = "workdir", + /** + * If you are running on self hosted runner, you can set this so it will add "sudo" to every buildah command if you dont want to run rootless. Defaults to false + * Required: false + * Default: "false" + */ + SELF_HOSTED_RUNNER_ROOT = "self-hosted-runner-root", } export enum Outputs { diff --git a/src/index.ts b/src/index.ts index abd8ad7..49955fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,8 +19,10 @@ export async function run(): Promise { } // get buildah cli + const self_hosted_runner = core.getInput(Inputs.SELF_HOSTED_RUNNER_ROOT) const buildahPath = await io.which("buildah", true); - const cli: BuildahCli = new BuildahCli(`sudo ${buildahPath}`); + const buildahExec = self_hosted_runner === "true" ? `sudo ${buildahPath}` : buildahPath; + const cli: BuildahCli = new BuildahCli(buildahExec); // print buildah version await cli.execute([ "version" ], { group: true });