6767 type : string
6868 description : ' QEMU static binaries Docker image (e.g. tonistiigi/binfmt:latest)'
6969 required : false
70- # same as docker/bake-action inputs (minus builder, targets, load, push)
70+ # same as docker/bake-action inputs (minus workdir, builder, targets, load, push)
7171 bake-source :
7272 type : string
7373 description : " Context to build from. Can be either local or a remote bake definition"
8080 type : string
8181 description : " List of bake definition files"
8282 required : false
83- bake-workdir :
84- type : string
85- description : " Working directory of bake execution"
86- required : false
87- default : ' .'
8883 bake-no-cache :
8984 type : boolean
9085 description : " Do not use cache when building the image"
@@ -119,9 +114,6 @@ jobs:
119114 outputs :
120115 includes : ${{ steps.set.outputs.includes }}
121116 steps :
122- -
123- name : Checkout
124- uses : actions/checkout@v4
125117 -
126118 name : Set includes
127119 id : set
@@ -137,29 +129,37 @@ jobs:
137129 throw new Error('Only one meta-image is allowed');
138130 }
139131
140- await core.group(`Install docker/actions-toolkit `, async () => {
141- await exec.exec('npm', ['install', '@docker/actions-toolkit']);
132+ await core.group(`Install npm dependencies `, async () => {
133+ await exec.exec('npm', ['install', '@docker/actions-toolkit', 'handlebars' ]);
142134 });
143135
144136 await core.group(`Validating definition`, async () => {
137+ const handlebars = require('handlebars');
138+ const { Context } = require('@docker/actions-toolkit/lib/context');
145139 const { Bake } = require('@docker/actions-toolkit/lib/buildx/bake');
140+
141+ let source = handlebars.compile(`${{ inputs.bake-source }}`)({
142+ defaultContext: Context.gitContext()
143+ });
144+ if (!source) {
145+ source = Context.gitContext();
146+ }
147+ if (source === '.') {
148+ source = '';
149+ }
150+
146151 const bake = new Bake();
147- def = await bake.getDefinition(
148- {
149- allow: `${{ inputs.bake-allow }}` ? `${{ inputs.bake-allow }}`.split(/[\r?\n,]+/).filter(Boolean) : [],
150- files: `${{ inputs.bake-files }}` ? `${{ inputs.bake-files }}`.split(/[\r?\n,]+/).filter(Boolean) : [],
151- noCache: ${{ inputs.bake-no-cache }},
152- overrides: `${{ inputs.bake-set }}` ? `${{ inputs.bake-set }}`.split(/[\r?\n,]+/).filter(Boolean) : [],
153- provenance: `${{ inputs.bake-provenance }}`,
154- sbom: `${{ inputs.bake-sbom }}`,
155- source: `${{ inputs.bake-source }}`,
156- targets: [`${{ inputs.target }}`],
157- githubToken: `${{ secrets.github-token || github.token }}`
158- },
159- {
160- cwd: `${{ inputs.bake-workdir }}`
161- }
162- );
152+ def = await bake.getDefinition({
153+ allow: `${{ inputs.bake-allow }}` ? `${{ inputs.bake-allow }}`.split(/[\r?\n,]+/).filter(Boolean) : [],
154+ files: `${{ inputs.bake-files }}` ? `${{ inputs.bake-files }}`.split(/[\r?\n,]+/).filter(Boolean) : [],
155+ noCache: ${{ inputs.bake-no-cache }},
156+ overrides: `${{ inputs.bake-set }}` ? `${{ inputs.bake-set }}`.split(/[\r?\n,]+/).filter(Boolean) : [],
157+ provenance: `${{ inputs.bake-provenance }}`,
158+ sbom: `${{ inputs.bake-sbom }}`,
159+ source: source,
160+ targets: [`${{ inputs.target }}`],
161+ githubToken: `${{ secrets.github-token || github.token }}`
162+ });
163163 if (!def) {
164164 throw new Error('Bake definition not set');
165165 }
0 commit comments