Merge pull request #5 from cachix/no-signing-key

Support running as a PR
This commit is contained in:
Domen Kožar 2019-10-03 16:47:27 +02:00 committed by GitHub
commit 9e7ef4fd59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

View file

@ -21,6 +21,12 @@ jobs:
name: cachix-action name: cachix-action
file: test.nix file: test.nix
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Test public cache no pushing
uses: ./
with:
name: cachix-action
file: test.nix
signingKey: ''
- name: Test private cache - name: Test private cache
uses: ./ uses: ./
with: with:

View file

@ -13,7 +13,6 @@ inputs:
description: 'Authentication token for Cachix, needed only for private cache access' description: 'Authentication token for Cachix, needed only for private cache access'
signingKey: signingKey:
description: 'Signing key secret retrieved after creating binary cache on https://cachix.org' description: 'Signing key secret retrieved after creating binary cache on https://cachix.org'
required: true
branding: branding:
color: 'blue' color: 'blue'
icon: 'database' icon: 'database'

View file

@ -8,7 +8,7 @@ async function run() {
const file = core.getInput('file'); const file = core.getInput('file');
const attributes = core.getInput('attributes'); const attributes = core.getInput('attributes');
const name = core.getInput('name', { required: true }); const name = core.getInput('name', { required: true });
const signingKey = core.getInput('signingKey', { required: true }); const signingKey = core.getInput('signingKey');
const authToken = core.getInput('authToken') const authToken = core.getInput('authToken')
core.startGroup('Installing Cachix') core.startGroup('Installing Cachix')
@ -25,7 +25,9 @@ async function run() {
await exec.exec('cachix', ['use', name]); await exec.exec('cachix', ['use', name]);
core.endGroup() core.endGroup()
core.exportVariable('CACHIX_SIGNING_KEY', signingKey) if (signingKey !== "") {
core.exportVariable('CACHIX_SIGNING_KEY', signingKey);
}
// TODO: cachix use --watch-store // TODO: cachix use --watch-store
core.startGroup(`Invoking nix-build`); core.startGroup(`Invoking nix-build`);
@ -41,9 +43,14 @@ async function run() {
await exec.exec('nix-build', args, options); await exec.exec('nix-build', args, options);
core.endGroup() core.endGroup()
core.startGroup(`Cachix: pushing to ` + name); // Needed for PRs
await exec.exec('cachix', ['push', name].concat(nonEmptySplit(paths, /\s+/))); if (signingKey !== "") {
core.endGroup() core.startGroup(`Cachix: pushing to ` + name);
await exec.exec('cachix', ['push', name].concat(nonEmptySplit(paths, /\s+/)));
core.endGroup()
} else {
console.log("No signing key. Assuming it's a pull request, nothing will be pushed.");
}
} catch (error) { } catch (error) {
core.setFailed(`Action failed with error: ${error}`); core.setFailed(`Action failed with error: ${error}`);
throw(error); throw(error);