Skip to content

Commit

Permalink
Add working-directory option
Browse files Browse the repository at this point in the history
Signed-off-by: Danilo Tuler <tuler@pobox.com>
  • Loading branch information
tuler committed Jun 10, 2022
1 parent 438d016 commit 49296ad
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,17 @@ Following inputs can be used as `step.with` keys
> targets: default,release
> ```

| Name | Type | Description |
|------------------|----------|------------------------------------|
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
| `files` | List/CSV | List of [bake definition files](https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md#file) |
| `targets` | List/CSV | List of bake targets |
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
| `pull` | Bool | Always attempt to pull a newer version of the image (default `false`) |
| `load` | Bool | Load is a shorthand for `--set=*.output=type=docker` (default `false`) |
| `push` | Bool | Push is a shorthand for `--set=*.output=type=registry` (default `false`) |
| `set` | List | List of [targets values to override](https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md#set) (eg: `targetpattern.key=value`) |
| Name | Type | Description |
|---------------------|----------|------------------------------------|
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
| `files` | List/CSV | List of [bake definition files](https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md#file) |
| `working-directory` | String | Working directory of execution |
| `targets` | List/CSV | List of bake targets |
| `no-cache` | Bool | Do not use cache when building the image (default `false`) |
| `pull` | Bool | Always attempt to pull a newer version of the image (default `false`) |
| `load` | Bool | Load is a shorthand for `--set=*.output=type=docker` (default `false`) |
| `push` | Bool | Push is a shorthand for `--set=*.output=type=registry` (default `false`) |
| `set` | List | List of [targets values to override](https://github.com/docker/buildx/blob/master/docs/reference/buildx_bake.md#set) (eg: `targetpattern.key=value`) |

### outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
files:
description: "List of bake definition files"
required: true
working-directory:
description: "Working directory of bake execution"
required: false
default: '.'
targets:
description: "List of bake targets"
required: false
Expand Down
4 changes: 2 additions & 2 deletions 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.

2 changes: 2 additions & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ let _tmpDir: string;
export interface Inputs {
builder: string;
files: string[];
workingDirectory: string;
targets: string[];
noCache: boolean;
pull: boolean;
Expand All @@ -35,6 +36,7 @@ export async function getInputs(): Promise<Inputs> {
return {
builder: core.getInput('builder'),
files: getInputList('files'),
workingDirectory: core.getInput('working-directory') || '.',
targets: getInputList('targets'),
noCache: core.getBooleanInput('no-cache'),
pull: core.getBooleanInput('pull'),
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ async function run(): Promise<void> {
const buildCmd = buildx.getCommand(args, standalone);

core.startGroup(`Bake definition`);
await exec.exec(buildCmd.command, [...buildCmd.args, '--print']);
await exec.exec(buildCmd.command, [...buildCmd.args, '--print'], {
cwd: inputs.workingDirectory
});
core.endGroup();

await exec
.getExecOutput(buildCmd.command, buildCmd.args, {
cwd: inputs.workingDirectory,
ignoreReturnCode: true
})
.then(res => {
Expand Down

0 comments on commit 49296ad

Please sign in to comment.