mirror of
https://git.flexiblyrigid.au/actions/bake-action.git
synced 2025-12-06 07:48:05 +08:00
add allow input
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@@ -691,3 +691,25 @@ jobs:
|
|||||||
./lint.hcl
|
./lint.hcl
|
||||||
env:
|
env:
|
||||||
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
|
DOCKER_BUILD_CHECKS_ANNOTATIONS: false
|
||||||
|
|
||||||
|
allow:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: ${{ inputs.buildx-version || env.BUILDX_VERSION }}
|
||||||
|
driver-opts: |
|
||||||
|
image=${{ inputs.buildkit-image || env.BUILDKIT_IMAGE }}
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/config.hcl
|
||||||
|
allow: network.host
|
||||||
|
targets: app-entitlements
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ The following inputs can be used as `step.with` keys
|
|||||||
|----------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|----------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
|
| `builder` | String | Builder instance (see [setup-buildx](https://github.com/docker/setup-buildx-action) action) |
|
||||||
| `source` | String | Context to build from. Can be either local (`.`) or a [remote bake definition](https://docs.docker.com/build/customize/bake/file-definition/#remote-definition) |
|
| `source` | String | Context to build from. Can be either local (`.`) or a [remote bake definition](https://docs.docker.com/build/customize/bake/file-definition/#remote-definition) |
|
||||||
|
| `allow` | List/CSV | Allow build to access specified resources (e.g., `network.host`) |
|
||||||
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
| `files` | List/CSV | List of [bake definition files](https://docs.docker.com/build/customize/bake/file-definition/) |
|
||||||
| `workdir` | String | Working directory of execution |
|
| `workdir` | String | Working directory of execution |
|
||||||
| `targets` | List/CSV | List of bake targets (`default` target used if empty) |
|
| `targets` | List/CSV | List of bake targets (`default` target used if empty) |
|
||||||
@@ -193,7 +194,7 @@ The following inputs can be used as `step.with` keys
|
|||||||
| `provenance` | Bool/String | [Provenance](https://docs.docker.com/build/attestations/slsa-provenance/) is a shorthand for `--set=*.attest=type=provenance` |
|
| `provenance` | Bool/String | [Provenance](https://docs.docker.com/build/attestations/slsa-provenance/) is a shorthand for `--set=*.attest=type=provenance` |
|
||||||
| `push` | Bool | Push is a shorthand for `--set=*.output=type=registry` (default `false`) |
|
| `push` | Bool | Push is a shorthand for `--set=*.output=type=registry` (default `false`) |
|
||||||
| `sbom` | Bool/String | [SBOM](https://docs.docker.com/build/attestations/sbom/) is a shorthand for `--set=*.attest=type=sbom` |
|
| `sbom` | Bool/String | [SBOM](https://docs.docker.com/build/attestations/sbom/) is a shorthand for `--set=*.attest=type=sbom` |
|
||||||
| `set` | List | List of [targets values to override](https://docs.docker.com/engine/reference/commandline/buildx_bake/#set) (eg: `targetpattern.key=value`) |
|
| `set` | List | List of [targets values to override](https://docs.docker.com/engine/reference/commandline/buildx_bake/#set) (e.g., `targetpattern.key=value`) |
|
||||||
| `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 }}`) |
|
| `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
|
### outputs
|
||||||
|
|||||||
@@ -330,6 +330,23 @@ describe('getArgs', () => {
|
|||||||
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
'--provenance', `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
12,
|
||||||
|
'0.17.0',
|
||||||
|
new Map<string, string>([
|
||||||
|
['allow', 'network.host'],
|
||||||
|
['load', 'false'],
|
||||||
|
['no-cache', 'false'],
|
||||||
|
['push', 'false'],
|
||||||
|
['pull', 'false'],
|
||||||
|
]),
|
||||||
|
[
|
||||||
|
'bake',
|
||||||
|
'--allow', 'network.host',
|
||||||
|
'--metadata-file', metadataJson,
|
||||||
|
"--provenance", `mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`
|
||||||
|
]
|
||||||
|
],
|
||||||
])(
|
])(
|
||||||
'[%d] given %p with %p as inputs, returns %p',
|
'[%d] given %p with %p as inputs, returns %p',
|
||||||
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
|
async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ inputs:
|
|||||||
source:
|
source:
|
||||||
description: "Context to build from. Can be either local or a remote bake definition"
|
description: "Context to build from. Can be either local or a remote bake definition"
|
||||||
required: false
|
required: false
|
||||||
|
allow:
|
||||||
|
description: "Allow build to access specified resources (e.g., network.host)"
|
||||||
|
required: false
|
||||||
files:
|
files:
|
||||||
description: "List of bake definition files"
|
description: "List of bake definition files"
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {Util} from '@docker/actions-toolkit/lib/util';
|
|||||||
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
import {BakeDefinition} from '@docker/actions-toolkit/lib/types/buildx/bake';
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
|
allow: string[];
|
||||||
builder: string;
|
builder: string;
|
||||||
files: string[];
|
files: string[];
|
||||||
workdir: string;
|
workdir: string;
|
||||||
@@ -28,6 +29,7 @@ export interface Inputs {
|
|||||||
|
|
||||||
export async function getInputs(): Promise<Inputs> {
|
export async function getInputs(): Promise<Inputs> {
|
||||||
return {
|
return {
|
||||||
|
allow: Util.getInputList('allow'),
|
||||||
builder: core.getInput('builder'),
|
builder: core.getInput('builder'),
|
||||||
files: Util.getInputList('files'),
|
files: Util.getInputList('files'),
|
||||||
workdir: core.getInput('workdir') || '.',
|
workdir: core.getInput('workdir') || '.',
|
||||||
@@ -80,6 +82,11 @@ async function getBakeArgs(inputs: Inputs, definition: BakeDefinition, toolkit:
|
|||||||
if (inputs.source) {
|
if (inputs.source) {
|
||||||
args.push(inputs.source);
|
args.push(inputs.source);
|
||||||
}
|
}
|
||||||
|
if (await toolkit.buildx.versionSatisfies('>=0.17.0')) {
|
||||||
|
if (inputs.allow.length > 0) {
|
||||||
|
args.push('--allow', inputs.allow.join(','));
|
||||||
|
}
|
||||||
|
}
|
||||||
await Util.asyncForEach(inputs.files, async file => {
|
await Util.asyncForEach(inputs.files, async file => {
|
||||||
args.push('--file', file);
|
args.push('--file', file);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,3 +42,8 @@ target "app-proxy" {
|
|||||||
inherits = ["app"]
|
inherits = ["app"]
|
||||||
dockerfile = "proxy.Dockerfile"
|
dockerfile = "proxy.Dockerfile"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
target "app-entitlements" {
|
||||||
|
inherits = ["app"]
|
||||||
|
entitlements = ["network.host"]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user