Skip to content

Commit 717c568

Browse files
committed
list-targets: use toolkit to sanitize inputs
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 37816e7 commit 717c568

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

subaction/list-targets/action.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,35 @@ outputs:
2222
runs:
2323
using: composite
2424
steps:
25+
-
26+
name: Install npm dependencies
27+
uses: actions/github-script@v7
28+
env:
29+
INPUT_ACTIONS-TOOLKIT-VERSION: '0.62.1'
30+
with:
31+
script: |
32+
const version = core.getInput('actions-toolkit-version') || 'latest';
33+
const dep = `@docker/actions-toolkit@${version}`;
34+
await core.group(`Installing ${dep}`, async () => {
35+
await exec.exec('npm', ['install', dep]);
36+
});
2537
-
2638
name: Generate
2739
id: generate
2840
uses: actions/github-script@v7
41+
env:
42+
INPUT_WORKDIR: ${{ inputs.workdir }}
43+
INPUT_FILES: ${{ inputs.files }}
44+
INPUT_TARGET: ${{ inputs.target }}
2945
with:
3046
script: |
31-
let def;
32-
const files = `${{ inputs.files }}` ? `${{ inputs.files }}`.split(/[\r?\n,]+/).filter(Boolean) : [];
33-
const target = `${{ inputs.target }}`;
47+
const { Util } = require('@docker/actions-toolkit/lib/util');
48+
49+
const workdir = core.getInput('workdir');
50+
const files = Util.getInputList('files');
51+
const target = core.getInput('target');
3452
53+
let def = {};
3554
await core.group(`Validating definition`, async () => {
3655
let args = ['buildx', 'bake'];
3756
for (const file of files) {
@@ -45,7 +64,7 @@ runs:
4564
const res = await exec.getExecOutput('docker', args, {
4665
ignoreReturnCode: true,
4766
silent: true,
48-
cwd: `${{ inputs.workdir }}`
67+
cwd: workdir
4968
});
5069
if (res.stderr.length > 0 && res.exitCode != 0) {
5170
throw new Error(res.stderr);

0 commit comments

Comments
 (0)