Skip to content
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
30 changes: 30 additions & 0 deletions .github/workflows/bake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ on:
type: string
description: "Bake target name for metadata (defaults to docker-metadata-action)"
required: false
chainguard-identity:
type: string
description: "UIDP of a Chainguard identity to assume via GitHub OIDC for keyless cgr.dev authentication"
required: false
chainguard-apk-host:
type: string
description: "Hostname for APK-related Chainguard authentication (passed through to chainguard-dev/setup-chainctl)"
required: false
default: apk.cgr.dev
chainguard-libraries-host:
type: string
description: "Hostname for Chainguard Libraries authentication (passed through to chainguard-dev/setup-chainctl)"
required: false
default: libraries.cgr.dev
secrets:
registry-auths:
description: "Raw authentication to registries, defined as YAML objects (for image output)"
Expand Down Expand Up @@ -907,6 +921,14 @@ jobs:
core.info(JSON.stringify(bakeOverrides, null, 2));
core.setOutput('overrides', bakeOverrides.join(os.EOL));
});
-
name: Set up chainctl
if: ${{ inputs.chainguard-identity != '' && inputs.push && inputs.output == 'image' }}
uses: chainguard-dev/setup-chainctl@2cddd35a2f120d9973e58094dc6878c93cf58c28 # v0.5.1
with:
identity: ${{ inputs.chainguard-identity }}
apk-host: ${{ inputs.chainguard-apk-host }}
libraries-host: ${{ inputs.chainguard-libraries-host }}
-
name: Login to registry
if: ${{ inputs.push && inputs.output == 'image' }}
Expand Down Expand Up @@ -1091,6 +1113,14 @@ jobs:
labels: ${{ inputs.meta-labels }}
annotations: ${{ inputs.meta-annotations }}
bake-target: ${{ inputs.meta-bake-target }}
-
name: Set up chainctl
if: ${{ inputs.chainguard-identity != '' && inputs.push && inputs.output == 'image' }}
uses: chainguard-dev/setup-chainctl@2cddd35a2f120d9973e58094dc6878c93cf58c28 # v0.5.1
with:
identity: ${{ inputs.chainguard-identity }}
apk-host: ${{ inputs.chainguard-apk-host }}
libraries-host: ${{ inputs.chainguard-libraries-host }}
-
name: Login to registry
if: ${{ inputs.push && inputs.output == 'image' }}
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,20 @@ on:
type: string
description: "Flavor defines a global behavior for meta-tags"
required: false
chainguard-identity:
type: string
description: "UIDP of a Chainguard identity to assume via GitHub OIDC for keyless cgr.dev authentication"
required: false
chainguard-apk-host:
type: string
description: "Hostname for APK-related Chainguard authentication (passed through to chainguard-dev/setup-chainctl)"
required: false
default: apk.cgr.dev
chainguard-libraries-host:
type: string
description: "Hostname for Chainguard Libraries authentication (passed through to chainguard-dev/setup-chainctl)"
required: false
default: libraries.cgr.dev
secrets:
registry-auths:
description: "Raw authentication to registries, defined as YAML objects (for image output)"
Expand Down Expand Up @@ -766,6 +780,14 @@ jobs:
// for a public repository, we set max provenance mode
core.setOutput('provenance', Build.resolveProvenanceAttrs(`mode=max,version=v1`));
}
-
name: Set up chainctl
if: ${{ inputs.chainguard-identity != '' && inputs.push && inputs.output == 'image' }}
uses: chainguard-dev/setup-chainctl@2cddd35a2f120d9973e58094dc6878c93cf58c28 # v0.5.1
with:
identity: ${{ inputs.chainguard-identity }}
apk-host: ${{ inputs.chainguard-apk-host }}
libraries-host: ${{ inputs.chainguard-libraries-host }}
-
name: Login to registry
if: ${{ inputs.push && inputs.output == 'image' }}
Expand Down Expand Up @@ -946,6 +968,14 @@ jobs:
flavor: ${{ inputs.meta-flavor }}
labels: ${{ inputs.meta-labels }}
annotations: ${{ inputs.meta-annotations }}
-
name: Set up chainctl
if: ${{ inputs.chainguard-identity != '' && inputs.push && inputs.output == 'image' }}
uses: chainguard-dev/setup-chainctl@2cddd35a2f120d9973e58094dc6878c93cf58c28 # v0.5.1
with:
identity: ${{ inputs.chainguard-identity }}
apk-host: ${{ inputs.chainguard-apk-host }}
libraries-host: ${{ inputs.chainguard-libraries-host }}
-
name: Login to registry
if: ${{ inputs.push && inputs.output == 'image' }}
Expand Down
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ___
* [Notes](#notes)
* [Runner mapping](#runner-mapping)
* [Metadata templates](#metadata-templates)
* [Chainguard keyless authentication](#chainguard-keyless-authentication)

## Overview

Expand Down Expand Up @@ -233,6 +234,9 @@ jobs:
| `meta-images` | List | | [List of images](https://github.com/docker/metadata-action?tab=readme-ov-file#images-input) to use as base name for tags (required for image output) |
| `meta-tags` | List | | [List of tags](https://github.com/docker/metadata-action?tab=readme-ov-file#tags-input) as key-value pair attributes |
| `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` |
| `chainguard-identity` | String | | UIDP of a Chainguard identity to assume via GitHub OIDC for keyless `cgr.dev` authentication. See [Chainguard keyless authentication](#chainguard-keyless-authentication) |
| `chainguard-apk-host` | String | `apk.cgr.dev` | Hostname for APK-related Chainguard authentication. Passed through to `chainguard-dev/setup-chainctl` |
| `chainguard-libraries-host` | String | `libraries.cgr.dev` | Hostname for Chainguard Libraries authentication. Passed through to `chainguard-dev/setup-chainctl` |

### Secrets

Expand Down Expand Up @@ -342,6 +346,9 @@ jobs:
| `meta-labels` | List | | [List of custom labels](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) |
| `meta-annotations` | List | | [List of custom annotations](https://github.com/docker/metadata-action?tab=readme-ov-file#overwrite-labels-and-annotations) |
| `meta-flavor` | List | | [Flavor](https://github.com/docker/metadata-action?tab=readme-ov-file#flavor-input) defines a global behavior for `meta-tags` |
| `chainguard-identity` | String | | UIDP of a Chainguard identity to assume via GitHub OIDC for keyless `cgr.dev` authentication. See [Chainguard keyless authentication](#chainguard-keyless-authentication) |
| `chainguard-apk-host` | String | `apk.cgr.dev` | Hostname for APK-related Chainguard authentication. Passed through to `chainguard-dev/setup-chainctl` |
| `chainguard-libraries-host` | String | `libraries.cgr.dev` | Hostname for Chainguard Libraries authentication. Passed through to `chainguard-dev/setup-chainctl` |

### Secrets

Expand Down Expand Up @@ -431,3 +438,35 @@ jobs:
*.args.VERSION={{meta.version}}
meta-images: name/app
```

### Chainguard keyless authentication

Setting `chainguard-identity` authenticates to `cgr.dev` via GitHub
OIDC, avoiding a static credential. The workflow runs
[`chainguard-dev/setup-chainctl`](https://github.com/chainguard-dev/setup-chainctl)
inside the `build` and `finalize` jobs so the token is minted on the
build runner and never crosses the `workflow_call` boundary (see
[`docker/github-builder#146`](https://github.com/docker/github-builder/issues/146)).

```yaml
jobs:
bake:
uses: docker/github-builder/.github/workflows/bake.yml@v1
permissions:
contents: read
id-token: write
with:
output: image
push: true
meta-images: cgr.dev/your-org/your-image
chainguard-identity: 70e4ec6.../79304d...
```

`chainguard-identity` can be combined with `registry-auths` for
multi-registry pushes.

> [!IMPORTANT]
> `chainguard-dev/setup-chainctl` also authenticates against
> `apk.cgr.dev` and `libraries.cgr.dev`. The assumed identity must be
> claim-matched for those audiences, or `chainguard-apk-host` /
> `chainguard-libraries-host` must be redirected.