mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-04 01:54:08 +02:00
Merge pull request #5 from cachix/no-signing-key
Support running as a PR
This commit is contained in:
commit
9e7ef4fd59
3 changed files with 18 additions and 6 deletions
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
|
|
@ -21,6 +21,12 @@ jobs:
|
|||
name: cachix-action
|
||||
file: test.nix
|
||||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||
- name: Test public cache no pushing
|
||||
uses: ./
|
||||
with:
|
||||
name: cachix-action
|
||||
file: test.nix
|
||||
signingKey: ''
|
||||
- name: Test private cache
|
||||
uses: ./
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ inputs:
|
|||
description: 'Authentication token for Cachix, needed only for private cache access'
|
||||
signingKey:
|
||||
description: 'Signing key secret retrieved after creating binary cache on https://cachix.org'
|
||||
required: true
|
||||
branding:
|
||||
color: 'blue'
|
||||
icon: 'database'
|
||||
|
|
|
|||
11
src/main.ts
11
src/main.ts
|
|
@ -8,7 +8,7 @@ async function run() {
|
|||
const file = core.getInput('file');
|
||||
const attributes = core.getInput('attributes');
|
||||
const name = core.getInput('name', { required: true });
|
||||
const signingKey = core.getInput('signingKey', { required: true });
|
||||
const signingKey = core.getInput('signingKey');
|
||||
const authToken = core.getInput('authToken')
|
||||
|
||||
core.startGroup('Installing Cachix')
|
||||
|
|
@ -25,7 +25,9 @@ async function run() {
|
|||
await exec.exec('cachix', ['use', name]);
|
||||
core.endGroup()
|
||||
|
||||
core.exportVariable('CACHIX_SIGNING_KEY', signingKey)
|
||||
if (signingKey !== "") {
|
||||
core.exportVariable('CACHIX_SIGNING_KEY', signingKey);
|
||||
}
|
||||
// TODO: cachix use --watch-store
|
||||
|
||||
core.startGroup(`Invoking nix-build`);
|
||||
|
|
@ -41,9 +43,14 @@ async function run() {
|
|||
await exec.exec('nix-build', args, options);
|
||||
core.endGroup()
|
||||
|
||||
// Needed for PRs
|
||||
if (signingKey !== "") {
|
||||
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) {
|
||||
core.setFailed(`Action failed with error: ${error}`);
|
||||
throw(error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue