Skip to content

Commit

Permalink
support building from remote bake definition
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Jun 24, 2022
1 parent 438d016 commit bb2d1b0
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ jobs:
targets: |
${{ matrix.target }}
push: false # set to true when https://github.com/docker/buildx/issues/179 is fixed
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1

error-msg:
runs-on: ubuntu-latest
Expand All @@ -71,10 +67,6 @@ jobs:
./test/config.hcl
set: |
*.platform=linux/amd64,linux/ppc64le,linux/s390x
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1
error-check:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -102,10 +94,6 @@ jobs:
echo "::error::Should have failed"
exit 1
fi
-
name: Dump context
if: always()
uses: crazy-max/ghaction-dump-context@v1
standalone:
runs-on: ubuntu-latest
Expand All @@ -126,3 +114,16 @@ jobs:
with:
files: |
./test/config.hcl
source:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Build
uses: ./
with:
source: https://github.com/docker/buildx.git#v0.8.2
targets: update-docs
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) |
| `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`) |
| `source` | String | [Remote bake definition](https://github.com/docker/buildx/blob/master/docs/guides/bake/file-definition.md#remote-definition) to build from |
### outputs
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ inputs:
set:
description: "List of targets values to override (eg. targetpattern.key=value)"
required: false
source:
description: "Remote bake definition to build from"
required: false

outputs:
metadata:
Expand Down
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.

7 changes: 6 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface Inputs {
load: boolean;
push: boolean;
set: string[];
source: string;
}

export function tmpDir(): string {
Expand All @@ -40,7 +41,8 @@ export async function getInputs(): Promise<Inputs> {
pull: core.getBooleanInput('pull'),
load: core.getBooleanInput('load'),
push: core.getBooleanInput('push'),
set: getInputList('set', true)
set: getInputList('set', true),
source: core.getInput('source')
};
}

Expand All @@ -55,6 +57,9 @@ export async function getArgs(inputs: Inputs, buildxVersion: string): Promise<Ar

async function getBakeArgs(inputs: Inputs, buildxVersion: string): Promise<Array<string>> {
const args: Array<string> = ['bake'];
if (inputs.source) {
args.push(inputs.source);
}
await asyncForEach(inputs.files, async file => {
args.push('--file', file);
});
Expand Down

0 comments on commit bb2d1b0

Please sign in to comment.