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 to self hosted runner that can change the user to root without sudo #126

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
<a id="image-tag-inputs"></a>
### Image and Tags Inputs
The `image` and `tags` inputs can be provided in one of two forms.
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5,159 changes: 5,158 additions & 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.

6 changes: 6 additions & 0 deletions src/generated/inputs-outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export async function run(): Promise<void> {
}

// 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(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 });
Expand Down