Skip to content

Commit a7071c9

Browse files
authored
Merge pull request #391 from crazy-max/bool-input
Use `core.getBooleanInput`
2 parents 93a9859 + 9199c83 commit a7071c9

File tree

3 files changed

+66
-18
lines changed

3 files changed

+66
-18
lines changed

__tests__/context.test.ts

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ describe('getArgs', () => {
143143
'0.4.1',
144144
new Map<string, string>([
145145
['context', '.'],
146+
['load', 'false'],
147+
['no-cache', 'false'],
148+
['push', 'false'],
149+
['pull', 'false']
146150
]),
147151
[
148152
'buildx',
@@ -155,6 +159,10 @@ describe('getArgs', () => {
155159
'0.4.2',
156160
new Map<string, string>([
157161
['build-args', 'MY_ARG=val1,val2,val3\nARG=val'],
162+
['load', 'false'],
163+
['no-cache', 'false'],
164+
['push', 'false'],
165+
['pull', 'false']
158166
]),
159167
[
160168
'buildx',
@@ -169,6 +177,10 @@ describe('getArgs', () => {
169177
'0.4.2',
170178
new Map<string, string>([
171179
['tags', 'name/app:7.4, name/app:latest'],
180+
['load', 'false'],
181+
['no-cache', 'false'],
182+
['push', 'false'],
183+
['pull', 'false']
172184
]),
173185
[
174186
'buildx',
@@ -184,7 +196,11 @@ describe('getArgs', () => {
184196
new Map<string, string>([
185197
['context', '.'],
186198
['labels', 'org.opencontainers.image.title=buildkit\norg.opencontainers.image.description=concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit'],
187-
['outputs', 'type=local,dest=./release-out']
199+
['outputs', 'type=local,dest=./release-out'],
200+
['load', 'false'],
201+
['no-cache', 'false'],
202+
['push', 'false'],
203+
['pull', 'false']
188204
]),
189205
[
190206
'buildx',
@@ -199,7 +215,11 @@ describe('getArgs', () => {
199215
'0.4.1',
200216
new Map<string, string>([
201217
['context', '.'],
202-
['platforms', 'linux/amd64,linux/arm64']
218+
['platforms', 'linux/amd64,linux/arm64'],
219+
['load', 'false'],
220+
['no-cache', 'false'],
221+
['push', 'false'],
222+
['pull', 'false']
203223
]),
204224
[
205225
'buildx',
@@ -211,7 +231,11 @@ describe('getArgs', () => {
211231
[
212232
'0.4.1',
213233
new Map<string, string>([
214-
['context', '.']
234+
['context', '.'],
235+
['load', 'false'],
236+
['no-cache', 'false'],
237+
['push', 'false'],
238+
['pull', 'false']
215239
]),
216240
[
217241
'buildx',
@@ -225,6 +249,10 @@ describe('getArgs', () => {
225249
new Map<string, string>([
226250
['context', '.'],
227251
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
252+
['load', 'false'],
253+
['no-cache', 'false'],
254+
['push', 'false'],
255+
['pull', 'false']
228256
]),
229257
[
230258
'buildx',
@@ -238,7 +266,11 @@ describe('getArgs', () => {
238266
'0.4.2',
239267
new Map<string, string>([
240268
['github-token', 'abcdefghijklmno0123456789'],
241-
['outputs', '.']
269+
['outputs', '.'],
270+
['load', 'false'],
271+
['no-cache', 'false'],
272+
['push', 'false'],
273+
['pull', 'false']
242274
]),
243275
[
244276
'buildx',
@@ -257,7 +289,10 @@ describe('getArgs', () => {
257289
['secrets', 'GIT_AUTH_TOKEN=abcdefghijklmno=0123456789'],
258290
['file', './test/Dockerfile'],
259291
['builder', 'builder-git-context-2'],
260-
['push', 'true']
292+
['load', 'false'],
293+
['no-cache', 'false'],
294+
['push', 'true'],
295+
['pull', 'false']
261296
]),
262297
[
263298
'buildx',
@@ -288,7 +323,10 @@ bbbb
288323
ccc"`],
289324
['file', './test/Dockerfile'],
290325
['builder', 'builder-git-context-2'],
291-
['push', 'true']
326+
['load', 'false'],
327+
['no-cache', 'false'],
328+
['push', 'true'],
329+
['pull', 'false']
292330
]),
293331
[
294332
'buildx',
@@ -322,7 +360,10 @@ bbbb
322360
ccc`],
323361
['file', './test/Dockerfile'],
324362
['builder', 'builder-git-context-2'],
325-
['push', 'true']
363+
['load', 'false'],
364+
['no-cache', 'false'],
365+
['push', 'true'],
366+
['pull', 'false']
326367
]),
327368
[
328369
'buildx',
@@ -348,7 +389,10 @@ ccc`],
348389
['file', './test/Dockerfile'],
349390
['builder', 'builder-git-context-2'],
350391
['network', 'host'],
351-
['push', 'true']
392+
['load', 'false'],
393+
['no-cache', 'false'],
394+
['push', 'true'],
395+
['pull', 'false']
352396
]),
353397
[
354398
'buildx',
@@ -367,7 +411,11 @@ ccc`],
367411
new Map<string, string>([
368412
['context', '.'],
369413
['labels', 'org.opencontainers.image.title=filter_results_top_n\norg.opencontainers.image.description=Reference implementation of operation "filter results (top-n)"'],
370-
['outputs', 'type=local,dest=./release-out']
414+
['outputs', 'type=local,dest=./release-out'],
415+
['load', 'false'],
416+
['no-cache', 'false'],
417+
['push', 'false'],
418+
['pull', 'false']
371419
]),
372420
[
373421
'buildx',
@@ -592,7 +640,7 @@ describe('setOutput', () => {
592640
});
593641
});
594642

595-
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
643+
// See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89
596644
function getInputName(name: string): string {
597645
return `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
598646
}

dist/index.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ export async function getInputs(defaultContext: string): Promise<Inputs> {
7474
context: core.getInput('context') || defaultContext,
7575
file: core.getInput('file'),
7676
labels: await getInputList('labels', true),
77-
load: /true/i.test(core.getInput('load')),
77+
load: core.getBooleanInput('load'),
7878
network: core.getInput('network'),
79-
noCache: /true/i.test(core.getInput('no-cache')),
79+
noCache: core.getBooleanInput('no-cache'),
8080
outputs: await getInputList('outputs', true),
8181
platforms: await getInputList('platforms'),
82-
pull: /true/i.test(core.getInput('pull')),
83-
push: /true/i.test(core.getInput('push')),
82+
pull: core.getBooleanInput('pull'),
83+
push: core.getBooleanInput('push'),
8484
secrets: await getInputList('secrets', true),
8585
secretFiles: await getInputList('secret-files', true),
8686
ssh: await getInputList('ssh'),

0 commit comments

Comments
 (0)