From 6fbf46bc232a8483b535c58dd80a9dcec65c9d64 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:28:52 -0500 Subject: [PATCH 1/4] Use `getBooleanInput` to parse flags --- action.yml | 2 ++ src/main.ts | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index abc2cc9b..10e2997b 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,7 @@ inputs: description: 'Signing key secret retrieved after creating binary cache on https://cachix.org' skipPush: description: 'Set to true to disable pushing build results to the cache' + default: false pathsToPush: description: 'Whitespace-separated list of paths to push. Leave empty to push every build result.' pushFilter: @@ -21,6 +22,7 @@ inputs: description: 'Extra command-line arguments to pass to cachix. If empty, defaults to -j8' skipAddingSubstituter: description: 'Set to true to skip adding cachix cache as a substitute' + default: false useDaemon: description: "Push store paths to the cache as they're built with the Cachix Daemon" default: true diff --git a/src/main.ts b/src/main.ts index bfc1eed2..b58885bb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,12 +14,12 @@ const name = core.getInput('name', { required: true }); const extraPullNames = core.getInput('extraPullNames'); const signingKey = core.getInput('signingKey'); const authToken = core.getInput('authToken') -const skipPush = core.getInput('skipPush'); +const skipPush = core.getBooleanInput('skipPush', { required: true }); const pathsToPush = core.getInput('pathsToPush'); const pushFilter = core.getInput('pushFilter'); const cachixArgs = core.getInput('cachixArgs'); -const skipAddingSubstituter = core.getInput('skipAddingSubstituter'); -const useDaemon = core.getBooleanInput('useDaemon'); +const skipAddingSubstituter = core.getBooleanInput('skipAddingSubstituter', { required: true }); +const useDaemon = core.getBooleanInput('useDaemon', { required: true }); const cachixBinInput = core.getInput('cachixBin'); const installCommand = core.getInput('installCommand') || @@ -64,7 +64,7 @@ async function setup() { await exec.exec(cachixBin, ['authtoken', authToken]); } - if (skipAddingSubstituter === 'true') { + if (skipAddingSubstituter) { core.info('Not adding Cachix cache to substituters as skipAddingSubstituter is set to true') } else { core.startGroup(`Cachix: using cache ` + name); @@ -156,7 +156,7 @@ async function upload() { const supportsDaemon = core.getState('supportsDaemon') === 'true'; try { - if (skipPush === 'true') { + if (skipPush) { core.info('Pushing is disabled as skipPush is set to true'); } else if (signingKey !== "" || authToken !== "") { if (useDaemon && supportsDaemon) { From f22a8780318a13dab1a410cb8656d635928a3763 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:31:40 -0500 Subject: [PATCH 2/4] Change flag default values to strings based on the docs --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 10e2997b..4867c5b0 100644 --- a/action.yml +++ b/action.yml @@ -13,7 +13,7 @@ inputs: description: 'Signing key secret retrieved after creating binary cache on https://cachix.org' skipPush: description: 'Set to true to disable pushing build results to the cache' - default: false + default: 'false' pathsToPush: description: 'Whitespace-separated list of paths to push. Leave empty to push every build result.' pushFilter: @@ -22,10 +22,10 @@ inputs: description: 'Extra command-line arguments to pass to cachix. If empty, defaults to -j8' skipAddingSubstituter: description: 'Set to true to skip adding cachix cache as a substitute' - default: false + default: 'false' useDaemon: description: "Push store paths to the cache as they're built with the Cachix Daemon" - default: true + default: 'true' cachixBin: description: 'Provide a custom path to the cachix binary' installCommand: From 7e50f0f071ba9c5ad5d30772a6d3ef50d71dfbca Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Thu, 21 Mar 2024 11:10:53 -0500 Subject: [PATCH 3/4] Make flag inputs not mandatory --- src/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index b58885bb..68ab4ee7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,12 +14,12 @@ const name = core.getInput('name', { required: true }); const extraPullNames = core.getInput('extraPullNames'); const signingKey = core.getInput('signingKey'); const authToken = core.getInput('authToken') -const skipPush = core.getBooleanInput('skipPush', { required: true }); +const skipPush = core.getBooleanInput('skipPush'); const pathsToPush = core.getInput('pathsToPush'); const pushFilter = core.getInput('pushFilter'); const cachixArgs = core.getInput('cachixArgs'); -const skipAddingSubstituter = core.getBooleanInput('skipAddingSubstituter', { required: true }); -const useDaemon = core.getBooleanInput('useDaemon', { required: true }); +const skipAddingSubstituter = core.getBooleanInput('skipAddingSubstituter'); +const useDaemon = core.getBooleanInput('useDaemon'); const cachixBinInput = core.getInput('cachixBin'); const installCommand = core.getInput('installCommand') || From bad8b779740c9e235d23d8d9703428230aaa5674 Mon Sep 17 00:00:00 2001 From: Sebastian Estrella <2049686+sestrella@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:54:47 -0500 Subject: [PATCH 4/4] Update dist/main/index.js --- dist/main/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/main/index.js b/dist/main/index.js index deb398a9..a75eb7d2 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -7740,11 +7740,11 @@ const name = core.getInput('name', { required: true }); const extraPullNames = core.getInput('extraPullNames'); const signingKey = core.getInput('signingKey'); const authToken = core.getInput('authToken'); -const skipPush = core.getInput('skipPush'); +const skipPush = core.getBooleanInput('skipPush'); const pathsToPush = core.getInput('pathsToPush'); const pushFilter = core.getInput('pushFilter'); const cachixArgs = core.getInput('cachixArgs'); -const skipAddingSubstituter = core.getInput('skipAddingSubstituter'); +const skipAddingSubstituter = core.getBooleanInput('skipAddingSubstituter'); const useDaemon = core.getBooleanInput('useDaemon'); const cachixBinInput = core.getInput('cachixBin'); const installCommand = core.getInput('installCommand') || @@ -7782,7 +7782,7 @@ async function setup() { if (authToken !== "") { await exec.exec(cachixBin, ['authtoken', authToken]); } - if (skipAddingSubstituter === 'true') { + if (skipAddingSubstituter) { core.info('Not adding Cachix cache to substituters as skipAddingSubstituter is set to true'); } else { @@ -7860,7 +7860,7 @@ async function upload() { const cachixBin = core.getState('cachixBin'); const supportsDaemon = core.getState('supportsDaemon') === 'true'; try { - if (skipPush === 'true') { + if (skipPush) { core.info('Pushing is disabled as skipPush is set to true'); } else if (signingKey !== "" || authToken !== "") {