Skip to content
Merged
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
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -873,3 +873,30 @@ jobs:
uses: ./
with:
source: ./test/attest

var:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
with:
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
driver-opts: |
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
-
name: Build
uses: ./
with:
source: ./test/go
targets: binary
vars: |
DESTDIR=/tmp/build
-
name: Check output folder
working-directory: /tmp/build
run: |
tree .
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ The following inputs can be used as `step.with` keys
| `set` | List | List of [targets values to override](https://docs.docker.com/engine/reference/commandline/buildx_bake/#set) (e.g., `targetpattern.key=value`) |
| `source` | String | Build source to use. Supports local path and [remote bake definition](https://docs.docker.com/build/bake/remote-definition/). With a local path, Bake runs from that directory, so all relative paths are resolved from it. See [Source semantics](#source-semantics). |
| `targets` | List/CSV | List of bake targets (`default` target used if empty) |
| `vars` | List | [Variables](https://docs.docker.com/build/bake/variables/) to set in the Bake definition as list of key-value pair |
| `github-token` | String | API token used to authenticate to a Git repository for [remote definitions](https://docs.docker.com/build/bake/remote-definition/) (default `${{ github.token }}`) |

### outputs
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ inputs:
targets:
description: "List of bake targets"
required: false
vars:
description: "Variables to set in the Bake definition as list of key-value pair"
required: false
github-token:
description: "API token used to authenticate to a Git repository for remote definitions"
default: ${{ github.token }}
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.

20 changes: 15 additions & 5 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface Inputs {
set: string[];
source: BakeContext;
targets: string[];
vars: string[];
'github-token': string;
}

Expand All @@ -47,6 +48,7 @@ export async function getInputs(): Promise<Inputs> {
set: Util.getInputList('set', {ignoreComma: true, quote: false}),
source: await getBakeContext(core.getInput('source')),
targets: Util.getInputList('targets'),
vars: Util.getInputList('vars', {ignoreComma: true, quote: false}),
'github-token': core.getInput('github-token')
};
}
Expand All @@ -70,22 +72,30 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
// allow filesystem entitlements by default
inputs.allow.push('fs=*');
}
await Util.asyncForEach(inputs.allow, async allow => {
await Util.asyncForEach(inputs.allow, async (allow: string) => {
args.push('--allow', allow);
});
}
if (inputs.call) {
if (!(await toolkit.buildx.versionSatisfies('>=0.16.0'))) {
throw new Error(`Buildx >= 0.16.0 is required to use the call flag.`);
throw new Error(`Buildx >= 0.16.0 is required to use the call input.`);
}
args.push('--call', inputs.call);
}
await Util.asyncForEach(inputs.files, async file => {
await Util.asyncForEach(inputs.files, async (file: string) => {
args.push('--file', file);
});
await Util.asyncForEach(inputs.set, async set => {
args.push('--set', set);
await Util.asyncForEach(inputs.set, async (s: string) => {
args.push('--set', s);
});
if (inputs.vars.length > 0) {
if (!(await toolkit.buildx.versionSatisfies('>=0.31.0'))) {
throw new Error(`Buildx >= 0.31.0 is required to use the vars input.`);
}
await Util.asyncForEach(inputs.vars, async (v: string) => {
args.push('--var', v);
});
}
if (await toolkit.buildx.versionSatisfies('>=0.6.0')) {
args.push('--metadata-file', toolkit.buildxBake.getMetadataFilePath());
}
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ actionsToolkit.run(
sbom: inputs.sbom,
source: inputs.source.remoteRef,
targets: inputs.targets,
vars: inputs.vars,
githubToken: gitAuthToken
},
{
Expand Down
Loading