From 2d1196fa3492cbcf16da61332ca3c95d2f4e7e6e Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Fri, 22 May 2026 17:41:46 +0200 Subject: [PATCH] preserve trailing whitespace in secrets input Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- __tests__/context.test.ts | 19 +++++++++++++++++++ src/context.ts | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/__tests__/context.test.ts b/__tests__/context.test.ts index cb3f31c..f5f8cd5 100644 --- a/__tests__/context.test.ts +++ b/__tests__/context.test.ts @@ -95,6 +95,25 @@ describe('getInputs', () => { expect(gitContextSpy).toHaveBeenCalledTimes(1); gitContextSpy.mockRestore(); }); + + test('requests untrimmed secrets input explicitly', async () => { + const gitContext = 'https://github.com/docker/build-push-action.git#refs/heads/master'; + const gitContextSpy = vi.spyOn(Build.prototype, 'gitContext').mockResolvedValue(gitContext); + const getInputList = vi.fn().mockReturnValue([]); + vi.resetModules(); + vi.doMock('@docker/actions-toolkit/lib/util.js', () => ({ + Util: { + getInputList + } + })); + setRequiredBooleanInputs(); + setInput('secrets', `"PRIVATE_SSH_KEY=test\n\n"`); + const context = await import('../src/context.js'); + await context.getInputs(); + expect(getInputList).toHaveBeenCalledWith('secrets', {ignoreComma: true, trimWhitespace: false}); + vi.doUnmock('@docker/actions-toolkit/lib/util.js'); + gitContextSpy.mockRestore(); + }); }); describe('getArgs', () => { diff --git a/src/context.ts b/src/context.ts index 41e0c78..890a454 100644 --- a/src/context.ts +++ b/src/context.ts @@ -76,7 +76,7 @@ export async function getInputs(): Promise { pull: core.getBooleanInput('pull'), push: core.getBooleanInput('push'), sbom: core.getInput('sbom'), - secrets: Util.getInputList('secrets', {ignoreComma: true}), + secrets: Util.getInputList('secrets', {ignoreComma: true, trimWhitespace: false}), 'secret-envs': Util.getInputList('secret-envs'), 'secret-files': Util.getInputList('secret-files', {ignoreComma: true}), 'shm-size': core.getInput('shm-size'),