Compare commits

..

No commits in common. "master" and "v6.15.0" have entirely different histories.

13 changed files with 130 additions and 387 deletions

View File

@ -1464,35 +1464,6 @@ jobs:
env: env:
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }} DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ matrix.days }}
export-legacy:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
legacy:
- false
- true
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
path: action
-
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: ./action
with:
file: ./test/Dockerfile
env:
DOCKER_BUILD_EXPORT_LEGACY: ${{ matrix.legacy }}
checks: checks:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
@ -1571,26 +1542,3 @@ jobs:
echo "::error::Should have failed" echo "::error::Should have failed"
exit 1 exit 1
fi fi
no-default-attestations:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
path: action
-
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: ./action
with:
file: ./test/Dockerfile
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1

View File

@ -67,6 +67,13 @@ jobs:
username_secret: GAR_USERNAME username_secret: GAR_USERNAME
password_secret: GAR_JSON_KEY password_secret: GAR_JSON_KEY
type: remote type: remote
-
name: Google Container Registry
registry: gcr.io
slug: gcr.io/sandbox-298914/test-docker-action
username_secret: GCR_USERNAME
password_secret: GCR_JSON_KEY
type: remote
- -
name: Azure Container Registry name: Azure Container Registry
registry: officialgithubactions.azurecr.io registry: officialgithubactions.azurecr.io

View File

@ -1,17 +0,0 @@
name: pr-assign-author
permissions:
contents: read
on:
pull_request_target:
types:
- opened
- reopened
jobs:
run:
uses: crazy-max/.github/.github/workflows/pr-assign-author.yml@1b673f36fad86812f538c1df9794904038a23cbf
permissions:
contents: read
pull-requests: write

View File

@ -15,14 +15,10 @@ jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
-
name: Checkout
uses: actions/checkout@v4
- -
name: Test name: Test
uses: docker/bake-action@v6 uses: docker/bake-action@v6
with: with:
source: .
targets: test targets: test
- -
name: Upload coverage name: Upload coverage

View File

@ -162,7 +162,6 @@ jobs:
* [Cache management](https://docs.docker.com/build/ci/github-actions/cache/) * [Cache management](https://docs.docker.com/build/ci/github-actions/cache/)
* [Export to Docker](https://docs.docker.com/build/ci/github-actions/export-docker/) * [Export to Docker](https://docs.docker.com/build/ci/github-actions/export-docker/)
* [Test before push](https://docs.docker.com/build/ci/github-actions/test-before-push/) * [Test before push](https://docs.docker.com/build/ci/github-actions/test-before-push/)
* [Validating build configuration](https://docs.docker.com/build/ci/github-actions/checks/)
* [Local registry](https://docs.docker.com/build/ci/github-actions/local-registry/) * [Local registry](https://docs.docker.com/build/ci/github-actions/local-registry/)
* [Share built image between jobs](https://docs.docker.com/build/ci/github-actions/share-image-jobs/) * [Share built image between jobs](https://docs.docker.com/build/ci/github-actions/share-image-jobs/)
* [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/) * [Named contexts](https://docs.docker.com/build/ci/github-actions/named-contexts/)
@ -186,19 +185,6 @@ additional details about the build, including build stats, logs, outputs, and
more. The build record can be imported to Docker Desktop for inspecting the more. The build record can be imported to Docker Desktop for inspecting the
build in greater detail. build in greater detail.
> [!WARNING]
>
> If you're using the [`actions/download-artifact`](https://github.com/actions/download-artifact)
> action in your workflow, you need to ignore the build record artifacts
> if `name` and `pattern` inputs are not specified ([defaults to download all artifacts](https://github.com/actions/download-artifact?tab=readme-ov-file#download-all-artifacts) of the workflow),
> otherwise the action will fail:
> ```yaml
> - uses: actions/download-artifact@v4
> with:
> pattern: "!*.dockerbuild"
> ```
> More info: https://github.com/actions/toolkit/pull/1874
Summaries are enabled by default, but can be disabled with the Summaries are enabled by default, but can be disabled with the
`DOCKER_BUILD_SUMMARY` [environment variable](#environment-variables). `DOCKER_BUILD_SUMMARY` [environment variable](#environment-variables).
@ -277,7 +263,6 @@ The following outputs are available:
| `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled | | `DOCKER_BUILD_SUMMARY` | Bool | `true` | If `false`, [build summary](https://docs.docker.com/build/ci/github-actions/build-summary/) generation is disabled |
| `DOCKER_BUILD_RECORD_UPLOAD` | Bool | `true` | If `false`, build record upload as [GitHub artifact](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) is disabled | | `DOCKER_BUILD_RECORD_UPLOAD` | Bool | `true` | If `false`, build record upload as [GitHub artifact](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts) is disabled |
| `DOCKER_BUILD_RECORD_RETENTION_DAYS` | Number | | Duration after which build record artifact will expire in days. Defaults to repository/org [retention settings](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy) if unset or `0` | | `DOCKER_BUILD_RECORD_RETENTION_DAYS` | Number | | Duration after which build record artifact will expire in days. Defaults to repository/org [retention settings](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration#artifact-and-log-retention-policy) if unset or `0` |
| `DOCKER_BUILD_EXPORT_LEGACY` | Bool | `false` | If `true`, exports build using legacy export-build tool instead of [`buildx history export` command](https://docs.docker.com/reference/cli/docker/buildx/history/export/) |
## Troubleshooting ## Troubleshooting

View File

@ -1,4 +1,4 @@
import {afterEach, beforeEach, describe, expect, jest, test} from '@jest/globals'; import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
@ -68,7 +68,6 @@ jest.spyOn(Builder.prototype, 'inspect').mockImplementation(async (): Promise<Bu
}); });
describe('getArgs', () => { describe('getArgs', () => {
const originalEnv = process.env;
beforeEach(() => { beforeEach(() => {
process.env = Object.keys(process.env).reduce((object, key) => { process.env = Object.keys(process.env).reduce((object, key) => {
if (!key.startsWith('INPUT_')) { if (!key.startsWith('INPUT_')) {
@ -77,9 +76,6 @@ describe('getArgs', () => {
return object; return object;
}, {}); }, {});
}); });
afterEach(() => {
process.env = originalEnv;
});
// prettier-ignore // prettier-ignore
test.each([ test.each([
@ -97,8 +93,7 @@ describe('getArgs', () => {
'build', 'build',
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'.' '.'
], ]
undefined
], ],
[ [
1, 1,
@ -121,8 +116,7 @@ ccc"`],
'--build-arg', `MULTILINE=aaaa\nbbbb\nccc`, '--build-arg', `MULTILINE=aaaa\nbbbb\nccc`,
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
2, 2,
@ -140,8 +134,7 @@ ccc"`],
'--tag', 'name/app:7.4', '--tag', 'name/app:7.4',
'--tag', 'name/app:latest', '--tag', 'name/app:latest',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
3, 3,
@ -161,8 +154,7 @@ ccc"`],
'--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit', '--label', 'org.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit',
'--output', 'type=local,dest=./release-out', '--output', 'type=local,dest=./release-out',
'.' '.'
], ]
undefined
], ],
[ [
4, 4,
@ -179,8 +171,7 @@ ccc"`],
'build', 'build',
'--platform', 'linux/amd64,linux/arm64', '--platform', 'linux/amd64,linux/arm64',
'.' '.'
], ]
undefined
], ],
[ [
5, 5,
@ -196,8 +187,7 @@ ccc"`],
'build', 'build',
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'.' '.'
], ]
undefined
], ],
[ [
6, 6,
@ -215,8 +205,7 @@ ccc"`],
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'.' '.'
], ]
undefined
], ],
[ [
7, 7,
@ -234,8 +223,7 @@ ccc"`],
'--output', '.', '--output', '.',
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
8, 8,
@ -261,8 +249,7 @@ ccc"`],
'--builder', 'builder-git-context-2', '--builder', 'builder-git-context-2',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
9, 9,
@ -299,8 +286,7 @@ ccc"`],
'--builder', 'builder-git-context-2', '--builder', 'builder-git-context-2',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
10, 10,
@ -337,8 +323,7 @@ ccc`],
'--builder', 'builder-git-context-2', '--builder', 'builder-git-context-2',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
11, 11,
@ -364,8 +349,7 @@ ccc`],
'--network', 'host', '--network', 'host',
'--push', '--push',
'https://github.com/docker/build-push-action.git#refs/heads/master' 'https://github.com/docker/build-push-action.git#refs/heads/master'
], ]
undefined
], ],
[ [
12, 12,
@ -385,8 +369,7 @@ ccc`],
'--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"', '--label', 'org.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"',
'--output', 'type=local,dest=./release-out', '--output', 'type=local,dest=./release-out',
'.' '.'
], ]
undefined
], ],
[ [
13, 13,
@ -412,8 +395,7 @@ ccc`],
'--network', 'host', '--network', 'host',
'--push', '--push',
'.' '.'
], ]
undefined
], ],
[ [
14, 14,
@ -443,8 +425,7 @@ nproc=3`],
'--ulimit', 'nproc=3', '--ulimit', 'nproc=3',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
15, 15,
@ -461,8 +442,7 @@ nproc=3`],
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'https://github.com/docker/build-push-action.git#refs/heads/master:docker' 'https://github.com/docker/build-push-action.git#refs/heads/master:docker'
], ]
undefined
], ],
[ [
16, 16,
@ -481,8 +461,7 @@ nproc=3`],
'--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`, '--secret', `id=GIT_AUTH_TOKEN,src=${tmpName}`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'https://github.com/docker/build-push-action.git#refs/heads/master:subdir' 'https://github.com/docker/build-push-action.git#refs/heads/master:subdir'
], ]
undefined
], ],
[ [
17, 17,
@ -500,8 +479,7 @@ nproc=3`],
'--iidfile', imageIDFilePath, '--iidfile', imageIDFilePath,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
18, 18,
@ -519,8 +497,7 @@ nproc=3`],
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
19, 19,
@ -539,8 +516,7 @@ nproc=3`],
'--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
20, 20,
@ -559,8 +535,7 @@ nproc=3`],
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
21, 21,
@ -579,8 +554,7 @@ nproc=3`],
'--attest', 'type=provenance,disabled=true', '--attest', 'type=provenance,disabled=true',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
22, 22,
@ -599,8 +573,7 @@ nproc=3`],
'--attest', 'type=provenance,builder-id=foo', '--attest', 'type=provenance,builder-id=foo',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
23, 23,
@ -619,8 +592,7 @@ nproc=3`],
"--output", 'type=docker', "--output", 'type=docker',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
24, 24,
@ -638,8 +610,7 @@ nproc=3`],
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
25, 25,
@ -659,8 +630,7 @@ nproc=3`],
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
26, 26,
@ -682,8 +652,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
27, 27,
@ -704,8 +673,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--load', '--load',
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
28, 28,
@ -725,8 +693,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
29, 29,
@ -750,8 +717,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
30, 30,
@ -771,8 +737,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,inline-only=true,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
31, 31,
@ -793,8 +758,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=sbom,disabled=false`, '--attest', `type=sbom,disabled=false`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
32, 32,
@ -814,8 +778,7 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=max,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
], ],
[ [
33, 33,
@ -834,37 +797,11 @@ ANOTHER_SECRET=ANOTHER_SECRET_ENV`]
'--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`, '--attest', `type=provenance,mode=min,builder-id=https://github.com/docker/build-push-action/actions/runs/123456789/attempts/1`,
'--metadata-file', metadataJson, '--metadata-file', metadataJson,
'.' '.'
], ]
undefined
],
[
34,
'0.13.1',
new Map<string, string>([
['context', '.'],
['load', 'false'],
['no-cache', 'false'],
['push', 'false'],
['pull', 'false']
]),
[
'build',
'--iidfile', imageIDFilePath,
'--metadata-file', metadataJson,
'.'
],
new Map<string, string>([
['BUILDX_NO_DEFAULT_ATTESTATIONS', '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>, envs: Map<string, string> | undefined) => { async (num: number, buildxVersion: string, inputs: Map<string, string>, expected: Array<string>) => {
if (envs) {
envs.forEach((value: string, name: string) => {
process.env[name] = value;
});
}
inputs.forEach((value: string, name: string) => { inputs.forEach((value: string, name: string) => {
setInput(name, value); setInput(name, value);
}); });

40
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -27,7 +27,7 @@
"packageManager": "yarn@3.6.3", "packageManager": "yarn@3.6.3",
"dependencies": { "dependencies": {
"@actions/core": "^1.11.1", "@actions/core": "^1.11.1",
"@docker/actions-toolkit": "0.62.1", "@docker/actions-toolkit": "0.56.0",
"handlebars": "^4.7.7" "handlebars": "^4.7.7"
}, },
"devDependencies": { "devDependencies": {

View File

@ -81,6 +81,25 @@ export async function getInputs(): Promise<Inputs> {
}; };
} }
export function sanitizeInputs(inputs: Inputs) {
const res = {};
for (const key of Object.keys(inputs)) {
if (key === 'github-token') {
continue;
}
const value: string | string[] | boolean = inputs[key];
if (typeof value === 'boolean' && value === false) {
continue;
} else if (Array.isArray(value) && value.length === 0) {
continue;
} else if (!value) {
continue;
}
res[key] = value;
}
return res;
}
export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> { export async function getArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<string>> {
const context = handlebars.compile(inputs.context)({ const context = handlebars.compile(inputs.context)({
defaultContext: Context.gitContext() defaultContext: Context.gitContext()
@ -245,7 +264,7 @@ async function getAttestArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<st
if (inputs.provenance) { if (inputs.provenance) {
args.push('--attest', Build.resolveAttestationAttrs(`type=provenance,${inputs.provenance}`)); args.push('--attest', Build.resolveAttestationAttrs(`type=provenance,${inputs.provenance}`));
provenanceSet = true; provenanceSet = true;
} else if (!hasAttestProvenance && !noDefaultAttestations() && (await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Build.hasDockerExporter(inputs.outputs, inputs.load)) { } else if (!hasAttestProvenance && (await toolkit.buildkit.versionSatisfies(inputs.builder, '>=0.11.0')) && !Build.hasDockerExporter(inputs.outputs, inputs.load)) {
// if provenance not specified in provenance or attests inputs and BuildKit // if provenance not specified in provenance or attests inputs and BuildKit
// version compatible for attestation, set default provenance. Also needs // version compatible for attestation, set default provenance. Also needs
// to make sure user doesn't want to explicitly load the image to docker. // to make sure user doesn't want to explicitly load the image to docker.
@ -277,10 +296,3 @@ async function getAttestArgs(inputs: Inputs, toolkit: Toolkit): Promise<Array<st
return args; return args;
} }
function noDefaultAttestations(): boolean {
if (process.env.BUILDX_NO_DEFAULT_ATTESTATIONS) {
return Util.parseBool(process.env.BUILDX_NO_DEFAULT_ATTESTATIONS);
}
return false;
}

View File

@ -24,8 +24,8 @@ actionsToolkit.run(
async () => { async () => {
const startedTime = new Date(); const startedTime = new Date();
const inputs: context.Inputs = await context.getInputs(); const inputs: context.Inputs = await context.getInputs();
stateHelper.setSummaryInputs(inputs);
core.debug(`inputs: ${JSON.stringify(inputs)}`); core.debug(`inputs: ${JSON.stringify(inputs)}`);
stateHelper.setInputs(inputs);
const toolkit = new Toolkit(); const toolkit = new Toolkit();
@ -85,8 +85,6 @@ actionsToolkit.run(
let builder: BuilderInfo; let builder: BuilderInfo;
await core.group(`Builder info`, async () => { await core.group(`Builder info`, async () => {
builder = await toolkit.builder.inspect(inputs.builder); builder = await toolkit.builder.inspect(inputs.builder);
stateHelper.setBuilderDriver(builder.driver ?? '');
stateHelper.setBuilderEndpoint(builder.nodes?.[0]?.endpoint ?? '');
core.info(JSON.stringify(builder, null, 2)); core.info(JSON.stringify(builder, null, 2));
}); });
@ -110,9 +108,9 @@ actionsToolkit.run(
if (inputs.call && inputs.call === 'check' && res.stdout.length > 0) { if (inputs.call && inputs.call === 'check' && res.stdout.length > 0) {
// checks warnings are printed to stdout: https://github.com/docker/buildx/pull/2647 // checks warnings are printed to stdout: https://github.com/docker/buildx/pull/2647
// take the first line with the message summaryzing the warnings // take the first line with the message summaryzing the warnings
err = new Error(res.stdout.split('\n')[0]?.trim()); err = Error(res.stdout.split('\n')[0]?.trim());
} else if (res.stderr.length > 0) { } else if (res.stderr.length > 0) {
err = new Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`); err = Error(`buildx failed with: ${res.stderr.match(/(.*)\s*$/)?.[0]?.trim() ?? 'unknown error'}`);
} }
} }
}); });
@ -175,6 +173,8 @@ actionsToolkit.run(
core.info('Build summary is not yet supported on GHES'); core.info('Build summary is not yet supported on GHES');
} else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) { } else if (!(await toolkit.buildx.versionSatisfies('>=0.13.0'))) {
core.info('Build summary requires Buildx >= 0.13.0'); core.info('Build summary requires Buildx >= 0.13.0');
} else if (builder && builder.driver === 'cloud') {
core.info('Build summary is not yet supported with Docker Build Cloud');
} else if (!ref) { } else if (!ref) {
core.info('Build summary requires a build reference'); core.info('Build summary requires a build reference');
} else { } else {
@ -200,8 +200,7 @@ actionsToolkit.run(
const buildxHistory = new BuildxHistory(); const buildxHistory = new BuildxHistory();
const exportRes = await buildxHistory.export({ const exportRes = await buildxHistory.export({
refs: stateHelper.buildRef ? [stateHelper.buildRef] : [], refs: stateHelper.buildRef ? [stateHelper.buildRef] : []
useContainer: buildExportLegacy()
}); });
core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`); core.info(`Build record written to ${exportRes.dockerbuildFilename} (${Util.formatFileSize(exportRes.dockerbuildSize)})`);
@ -217,9 +216,7 @@ actionsToolkit.run(
await GitHub.writeBuildSummary({ await GitHub.writeBuildSummary({
exportRes: exportRes, exportRes: exportRes,
uploadRes: uploadRes, uploadRes: uploadRes,
inputs: stateHelper.summaryInputs, inputs: stateHelper.inputs
driver: stateHelper.builderDriver,
endpoint: stateHelper.builderEndpoint
}); });
} catch (e) { } catch (e) {
core.warning(e.message); core.warning(e.message);
@ -228,11 +225,7 @@ actionsToolkit.run(
} }
if (stateHelper.tmpDir.length > 0) { if (stateHelper.tmpDir.length > 0) {
await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => { await core.group(`Removing temp folder ${stateHelper.tmpDir}`, async () => {
try {
fs.rmSync(stateHelper.tmpDir, {recursive: true}); fs.rmSync(stateHelper.tmpDir, {recursive: true});
} catch (e) {
core.warning(`Failed to remove temp folder ${stateHelper.tmpDir}`);
}
}); });
} }
} }
@ -292,15 +285,8 @@ function buildRecordRetentionDays(): number | undefined {
if (val) { if (val) {
const res = parseInt(val); const res = parseInt(val);
if (isNaN(res)) { if (isNaN(res)) {
throw new Error(`Invalid build record retention days: ${val}`); throw Error(`Invalid build record retention days: ${val}`);
} }
return res; return res;
} }
} }
function buildExportLegacy(): boolean {
if (process.env.DOCKER_BUILD_EXPORT_LEGACY) {
return Util.parseBool(process.env.DOCKER_BUILD_EXPORT_LEGACY);
}
return false;
}

View File

@ -1,15 +1,9 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import {Build} from '@docker/actions-toolkit/lib/buildx/build'; import {Inputs, sanitizeInputs} from './context';
import {Inputs} from './context';
export const tmpDir = process.env['STATE_tmpDir'] || ''; export const tmpDir = process.env['STATE_tmpDir'] || '';
export const inputs = process.env['STATE_inputs'] ? JSON.parse(process.env['STATE_inputs']) : undefined;
export const builderDriver = process.env['STATE_builderDriver'] || '';
export const builderEndpoint = process.env['STATE_builderEndpoint'] || '';
export const summaryInputs = process.env['STATE_summaryInputs'] ? JSON.parse(process.env['STATE_summaryInputs']) : undefined;
export const buildRef = process.env['STATE_buildRef'] || ''; export const buildRef = process.env['STATE_buildRef'] || '';
export const isSummarySupported = !!process.env['STATE_isSummarySupported']; export const isSummarySupported = !!process.env['STATE_isSummarySupported'];
@ -17,12 +11,8 @@ export function setTmpDir(tmpDir: string) {
core.saveState('tmpDir', tmpDir); core.saveState('tmpDir', tmpDir);
} }
export function setBuilderDriver(builderDriver: string) { export function setInputs(inputs: Inputs) {
core.saveState('builderDriver', builderDriver); core.saveState('inputs', JSON.stringify(sanitizeInputs(inputs)));
}
export function setBuilderEndpoint(builderEndpoint: string) {
core.saveState('builderEndpoint', builderEndpoint);
} }
export function setBuildRef(buildRef: string) { export function setBuildRef(buildRef: string) {
@ -32,39 +22,3 @@ export function setBuildRef(buildRef: string) {
export function setSummarySupported() { export function setSummarySupported() {
core.saveState('isSummarySupported', 'true'); core.saveState('isSummarySupported', 'true');
} }
export function setSummaryInputs(inputs: Inputs) {
const res = {};
for (const key of Object.keys(inputs)) {
if (key === 'github-token') {
continue;
}
const value: string | string[] | boolean = inputs[key];
if (typeof value === 'boolean' && !value) {
continue;
} else if (Array.isArray(value)) {
if (value.length === 0) {
continue;
} else if (key === 'secrets' && value.length > 0) {
const secretKeys: string[] = [];
for (const secret of value) {
try {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [skey, _] = Build.parseSecretKvp(secret, true);
secretKeys.push(skey);
} catch (err) {
// ignore invalid secret
}
}
if (secretKeys.length > 0) {
res[key] = secretKeys;
}
continue;
}
} else if (!value) {
continue;
}
res[key] = value;
}
core.saveState('summaryInputs', JSON.stringify(res));
}

129
yarn.lock
View File

@ -12,9 +12,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@actions/artifact@npm:^2.3.2": "@actions/artifact@npm:^2.2.2":
version: 2.3.2 version: 2.2.2
resolution: "@actions/artifact@npm:2.3.2" resolution: "@actions/artifact@npm:2.2.2"
dependencies: dependencies:
"@actions/core": ^1.10.0 "@actions/core": ^1.10.0
"@actions/github": ^5.1.1 "@actions/github": ^5.1.1
@ -28,13 +28,13 @@ __metadata:
archiver: ^7.0.1 archiver: ^7.0.1
jwt-decode: ^3.1.2 jwt-decode: ^3.1.2
unzip-stream: ^0.3.1 unzip-stream: ^0.3.1
checksum: 78ee41b43800accb2f3527e1733217c43d53693e7f96ce2470b16890fb84f5c2ebaaa6048ccdb6cfe188b54c02779ec99623c6932558e757f6829cfde203cf2c checksum: 1501b3d0ceb671f370786ccf70014de9586c5a78c95d235248fc16c73bf928f8de2aa932a679258f6d9bc2f2e570648d830551af9f063298f05d19f3330b33bc
languageName: node languageName: node
linkType: hard linkType: hard
"@actions/cache@npm:^4.0.3": "@actions/cache@npm:^4.0.2":
version: 4.0.3 version: 4.0.2
resolution: "@actions/cache@npm:4.0.3" resolution: "@actions/cache@npm:4.0.2"
dependencies: dependencies:
"@actions/core": ^1.11.1 "@actions/core": ^1.11.1
"@actions/exec": ^1.0.1 "@actions/exec": ^1.0.1
@ -46,7 +46,7 @@ __metadata:
"@azure/storage-blob": ^12.13.0 "@azure/storage-blob": ^12.13.0
"@protobuf-ts/plugin": ^2.9.4 "@protobuf-ts/plugin": ^2.9.4
semver: ^6.3.1 semver: ^6.3.1
checksum: ee9c2a21a70bd3f35c63f302af478e23f135c26deb77ea2e4eed29c62766a4b201fc7435651c0d56fa504c02d203107e3bdfda1dba18a3ee09338e1dfc3f2fe8 checksum: 208f11238a26194f331b329bb99d50a87c1a3ccef1dbae181e5c142b3faf41715203e0c5cbc491519d3d97540a68fbd418c25fb6e16caabf76248c40867c02b4
languageName: node languageName: node
linkType: hard linkType: hard
@ -91,18 +91,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@actions/github@npm:^6.0.1": "@actions/github@npm:^6.0.0":
version: 6.0.1 version: 6.0.0
resolution: "@actions/github@npm:6.0.1" resolution: "@actions/github@npm:6.0.0"
dependencies: dependencies:
"@actions/http-client": ^2.2.0 "@actions/http-client": ^2.2.0
"@octokit/core": ^5.0.1 "@octokit/core": ^5.0.1
"@octokit/plugin-paginate-rest": ^9.2.2 "@octokit/plugin-paginate-rest": ^9.0.0
"@octokit/plugin-rest-endpoint-methods": ^10.4.0 "@octokit/plugin-rest-endpoint-methods": ^10.0.0
"@octokit/request": ^8.4.1 checksum: 81831a78377175d8825fc0b94247ff366c0e87ad1dfa48df9b30b8659506f216dcf1e2d3124fcd318839b92c24ba20165e238b3cc11a34db89c69c40825e9ccf
"@octokit/request-error": ^5.1.1
undici: ^5.28.5
checksum: ba6a162a5727dea2f3f3fc450e02c5b336ceb65a0e26ba9ad9c62b20f4f5b2625ca347a9311a4905ef3c92378ca022caba841a283cb7f2e4175d79e3d1ecaf12
languageName: node languageName: node
linkType: hard linkType: hard
@ -1075,15 +1072,15 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@docker/actions-toolkit@npm:0.62.1": "@docker/actions-toolkit@npm:0.56.0":
version: 0.62.1 version: 0.56.0
resolution: "@docker/actions-toolkit@npm:0.62.1" resolution: "@docker/actions-toolkit@npm:0.56.0"
dependencies: dependencies:
"@actions/artifact": ^2.3.2 "@actions/artifact": ^2.2.2
"@actions/cache": ^4.0.3 "@actions/cache": ^4.0.2
"@actions/core": ^1.11.1 "@actions/core": ^1.11.1
"@actions/exec": ^1.1.1 "@actions/exec": ^1.1.1
"@actions/github": ^6.0.1 "@actions/github": ^6.0.0
"@actions/http-client": ^2.2.3 "@actions/http-client": ^2.2.3
"@actions/io": ^1.1.3 "@actions/io": ^1.1.3
"@actions/tool-cache": ^2.0.2 "@actions/tool-cache": ^2.0.2
@ -1097,10 +1094,10 @@ __metadata:
he: ^1.2.0 he: ^1.2.0
js-yaml: ^4.1.0 js-yaml: ^4.1.0
jwt-decode: ^4.0.0 jwt-decode: ^4.0.0
semver: ^7.7.2 semver: ^7.7.1
tar-stream: ^3.1.7 tar-stream: ^3.1.7
tmp: ^0.2.3 tmp: ^0.2.3
checksum: 72dfef5073c7b638a73b53ccd48ec9dc3fa0e0c1b1b0aaf711fc872ef4ef0a882909271c01913f335efc5f868e4062e6e7720b92d6c3a605ecb6cc30d3001f9d checksum: 0f1b569f8bb206399f8c26e566c78e30e4a311bbd64486016e7fa1d35fbbb4c94d4f55afa6b711afa4b41c5835b40b038f48c3d1bfdfdc6f7c6680973e922d9e
languageName: node languageName: node
linkType: hard linkType: hard
@ -1689,16 +1686,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/endpoint@npm:^9.0.6":
version: 9.0.6
resolution: "@octokit/endpoint@npm:9.0.6"
dependencies:
"@octokit/types": ^13.1.0
universal-user-agent: ^6.0.0
checksum: f853c08f0777a8cc7c3d2509835d478e11a76d722f807d4f2ad7c0e64bf4dd159536409f466b367a907886aa3b78574d3d09ed95ac462c769e4fccaaad81e72a
languageName: node
linkType: hard
"@octokit/graphql@npm:^4.5.8": "@octokit/graphql@npm:^4.5.8":
version: 4.8.0 version: 4.8.0
resolution: "@octokit/graphql@npm:4.8.0" resolution: "@octokit/graphql@npm:4.8.0"
@ -1742,13 +1729,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/openapi-types@npm:^24.2.0":
version: 24.2.0
resolution: "@octokit/openapi-types@npm:24.2.0"
checksum: 3c2d2f4cafd21c8a1e6a6fe6b56df6a3c09bc52ab6f829c151f9397694d028aa183ae856f08e006ee7ecaa7bd7eb413a903fbc0ffa6403e7b284ddcda20b1294
languageName: node
linkType: hard
"@octokit/plugin-paginate-rest@npm:^2.17.0": "@octokit/plugin-paginate-rest@npm:^2.17.0":
version: 2.21.3 version: 2.21.3
resolution: "@octokit/plugin-paginate-rest@npm:2.21.3" resolution: "@octokit/plugin-paginate-rest@npm:2.21.3"
@ -1760,14 +1740,14 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/plugin-paginate-rest@npm:^9.2.2": "@octokit/plugin-paginate-rest@npm:^9.0.0":
version: 9.2.2 version: 9.0.0
resolution: "@octokit/plugin-paginate-rest@npm:9.2.2" resolution: "@octokit/plugin-paginate-rest@npm:9.0.0"
dependencies: dependencies:
"@octokit/types": ^12.6.0 "@octokit/types": ^12.0.0
peerDependencies: peerDependencies:
"@octokit/core": 5 "@octokit/core": ">=5"
checksum: ea2a3ebf6abc128a1996c5ff7148ebe755ee2ed001aa0c1d3088d67a9d78b093d84820e3ec73bfb165ca8774943a1158afdae4cf7b90b0a07f12ebbe1d8a428b checksum: 4a8543f3e45c4916f94edc57d66106ee60da9fd4edccd7c3a2ddd00da1fc4eb2e1b2bcb3d6cb981a050edf883100c5004d0b81497568d4ac9138310a2188a458
languageName: node languageName: node
linkType: hard linkType: hard
@ -1780,7 +1760,7 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/plugin-rest-endpoint-methods@npm:^10.4.0": "@octokit/plugin-rest-endpoint-methods@npm:^10.0.0, @octokit/plugin-rest-endpoint-methods@npm:^10.4.0":
version: 10.4.0 version: 10.4.0
resolution: "@octokit/plugin-rest-endpoint-methods@npm:10.4.0" resolution: "@octokit/plugin-rest-endpoint-methods@npm:10.4.0"
dependencies: dependencies:
@ -1835,17 +1815,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/request-error@npm:^5.1.1":
version: 5.1.1
resolution: "@octokit/request-error@npm:5.1.1"
dependencies:
"@octokit/types": ^13.1.0
deprecation: ^2.0.0
once: ^1.4.0
checksum: 17d0b3f59c2a8a285715bfe6a85168d9c417aa7a0ff553b9be4198a3bc8bb00384a3530221a448eb19f8f07ea9fc48d264869624f5f84fa63a948a7af8cddc8c
languageName: node
linkType: hard
"@octokit/request@npm:^5.6.0, @octokit/request@npm:^5.6.3": "@octokit/request@npm:^5.6.0, @octokit/request@npm:^5.6.3":
version: 5.6.3 version: 5.6.3
resolution: "@octokit/request@npm:5.6.3" resolution: "@octokit/request@npm:5.6.3"
@ -1873,18 +1842,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/request@npm:^8.4.1":
version: 8.4.1
resolution: "@octokit/request@npm:8.4.1"
dependencies:
"@octokit/endpoint": ^9.0.6
"@octokit/request-error": ^5.1.1
"@octokit/types": ^13.1.0
universal-user-agent: ^6.0.0
checksum: 0ba76728583543baeef9fda98690bc86c57e0a3ccac8c189d2b7d144d248c89167eb37a071ed8fead8f4da0a1c55c4dd98a8fc598769c263b95179fb200959de
languageName: node
linkType: hard
"@octokit/types@npm:^12.0.0": "@octokit/types@npm:^12.0.0":
version: 12.0.0 version: 12.0.0
resolution: "@octokit/types@npm:12.0.0" resolution: "@octokit/types@npm:12.0.0"
@ -1903,15 +1860,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@octokit/types@npm:^13.1.0":
version: 13.10.0
resolution: "@octokit/types@npm:13.10.0"
dependencies:
"@octokit/openapi-types": ^24.2.0
checksum: fca3764548d5872535b9025c3b5fe6373fe588b287cb5b5259364796c1931bbe5e9ab8a86a5274ce43bb2b3e43b730067c3b86b6b1ade12a98cd59b2e8b3610d
languageName: node
linkType: hard
"@octokit/types@npm:^6.0.3, @octokit/types@npm:^6.16.1, @octokit/types@npm:^6.39.0, @octokit/types@npm:^6.40.0": "@octokit/types@npm:^6.0.3, @octokit/types@npm:^6.16.1, @octokit/types@npm:^6.39.0, @octokit/types@npm:^6.40.0":
version: 6.41.0 version: 6.41.0
resolution: "@octokit/types@npm:6.41.0" resolution: "@octokit/types@npm:6.41.0"
@ -3195,7 +3143,7 @@ __metadata:
resolution: "docker-build-push@workspace:." resolution: "docker-build-push@workspace:."
dependencies: dependencies:
"@actions/core": ^1.11.1 "@actions/core": ^1.11.1
"@docker/actions-toolkit": 0.62.1 "@docker/actions-toolkit": 0.56.0
"@types/node": ^20.12.12 "@types/node": ^20.12.12
"@typescript-eslint/eslint-plugin": ^7.9.0 "@typescript-eslint/eslint-plugin": ^7.9.0
"@typescript-eslint/parser": ^7.9.0 "@typescript-eslint/parser": ^7.9.0
@ -5877,12 +5825,12 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"semver@npm:^7.7.2": "semver@npm:^7.7.1":
version: 7.7.2 version: 7.7.1
resolution: "semver@npm:7.7.2" resolution: "semver@npm:7.7.1"
bin: bin:
semver: bin/semver.js semver: bin/semver.js
checksum: dd94ba8f1cbc903d8eeb4dd8bf19f46b3deb14262b6717d0de3c804b594058ae785ef2e4b46c5c3b58733c99c83339068203002f9e37cfe44f7e2cc5e3d2f621 checksum: 586b825d36874007c9382d9e1ad8f93888d8670040add24a28e06a910aeebd673a2eb9e3bf169c6679d9245e66efb9057e0852e70d9daa6c27372aab1dda7104
languageName: node languageName: node
linkType: hard linkType: hard
@ -6488,15 +6436,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"undici@npm:^5.28.5":
version: 5.29.0
resolution: "undici@npm:5.29.0"
dependencies:
"@fastify/busboy": ^2.0.0
checksum: a25b5462c1b6ffb974f5ffc492ffd64146a9983aad0cbda6fde65e2b22f6f1acd43f09beacc66cc47624a113bd0c684ffc60366102b6a21b038fbfafb7d75195
languageName: node
linkType: hard
"unique-filename@npm:^3.0.0": "unique-filename@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "unique-filename@npm:3.0.0" resolution: "unique-filename@npm:3.0.0"