bake: set cwd:// prefix for bake files path
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
36ea4ee555
commit
61879b94bc
|
@ -455,3 +455,29 @@ jobs:
|
||||||
-
|
-
|
||||||
name: Print envs
|
name: Print envs
|
||||||
run: env|sort
|
run: env|sort
|
||||||
|
|
||||||
|
bake-cwd:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
-
|
||||||
|
name: Docker meta
|
||||||
|
id: docker_meta
|
||||||
|
uses: ./
|
||||||
|
-
|
||||||
|
name: Build
|
||||||
|
uses: docker/bake-action@v4
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
./test/docker-bake.hcl
|
||||||
|
${{ steps.docker_meta.outputs.bake-file-tags }}
|
||||||
|
${{ steps.docker_meta.outputs.bake-file-labels }}
|
||||||
|
targets: |
|
||||||
|
release
|
||||||
|
|
|
@ -94,17 +94,22 @@ actionsToolkit.run(
|
||||||
setOutput('json', JSON.stringify(jsonOutput));
|
setOutput('json', JSON.stringify(jsonOutput));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Specifying local and remote bake files is supported since Buildx 0.12.0.
|
||||||
|
// Set cwd:// prefix for local bake files to avoid ambiguity with remote
|
||||||
|
// https://github.com/docker/buildx/pull/1838
|
||||||
|
const bakeFileCwdPrefix = (await toolkit.buildx.versionSatisfies('>=0.12.0').catch(() => false)) ? 'cwd://' : '';
|
||||||
|
|
||||||
// Bake files
|
// Bake files
|
||||||
for (const kind of ['tags', 'labels', 'annotations:' + annotationsLevels]) {
|
for (const kind of ['tags', 'labels', 'annotations:' + annotationsLevels]) {
|
||||||
const outputName = kind.split(':')[0];
|
const outputName = kind.split(':')[0];
|
||||||
const bakeFile: string = meta.getBakeFile(kind);
|
const bakeFile: string = meta.getBakeFile(kind);
|
||||||
await core.group(`Bake file definition (${outputName})`, async () => {
|
await core.group(`Bake file definition (${outputName})`, async () => {
|
||||||
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
core.info(fs.readFileSync(bakeFile, 'utf8'));
|
||||||
setOutput(`bake-file-${outputName}`, bakeFile);
|
setOutput(`bake-file-${outputName}`, `${bakeFileCwdPrefix}${bakeFile}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bake file with tags and labels
|
// Bake file with tags and labels
|
||||||
setOutput(`bake-file`, meta.getBakeFileTagsLabels());
|
setOutput(`bake-file`, `${bakeFileCwdPrefix}${meta.getBakeFileTagsLabels()}`);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue