Skip to content

Commit

Permalink
Merge pull request #66 from cachix/auth-token-push
Browse files Browse the repository at this point in the history
allow auth token to be enough for pushing paths
  • Loading branch information
domenkozar authored Nov 10, 2020
2 parents e689c31 + 2597152 commit 38dc1a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 10 additions & 4 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ function setup() {
core.startGroup('Cachix: installing');
yield exec.exec('bash', ['-c', installCommand]);
core.endGroup();
// for private caches
// for managed signing key and private caches
if (authToken !== "") {
yield exec.exec(cachixExecutable, ['authtoken', authToken]);
}
Expand All @@ -1070,9 +1070,9 @@ function setup() {
}
if (signingKey !== "") {
core.exportVariable('CACHIX_SIGNING_KEY', signingKey);
// Remember existing store paths
yield exec.exec("sh", ["-c", `nix path-info --all | grep -v '\.drv$' > /tmp/store-path-pre-build`]);
}
// Remember existing store paths
yield exec.exec("sh", ["-c", `nix path-info --all | grep -v '\.drv$' > /tmp/store-path-pre-build`]);
}
catch (error) {
core.setFailed(`Action failed with error: ${error}`);
Expand All @@ -1083,11 +1083,17 @@ function setup() {
function upload() {
return __awaiter(this, void 0, void 0, function* () {
try {
if (signingKey !== "" && skipPush !== 'true') {
if (skipPush === 'true') {
core.info('Pushing is disabled as skipPush is set to true');
}
else if (signingKey !== "" || authToken !== "") {
core.startGroup('Cachix: pushing paths');
child_process_1.execFileSync(`${__dirname}/push-paths.sh`, [cachixExecutable, name], { stdio: 'inherit' });
core.endGroup();
}
else {
core.info('Pushing is disabled as signing key nor auth token are set.');
}
}
catch (error) {
core.setFailed(`Action failed with error: ${error}`);
Expand Down
12 changes: 8 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function setup() {
await exec.exec('bash', ['-c', installCommand]);
core.endGroup()

// for private caches
// for managed signing key and private caches
if (authToken !== "") {
await exec.exec(cachixExecutable, ['authtoken', authToken]);
}
Expand All @@ -43,9 +43,9 @@ async function setup() {

if (signingKey !== "") {
core.exportVariable('CACHIX_SIGNING_KEY', signingKey);
// Remember existing store paths
await exec.exec("sh", ["-c", `nix path-info --all | grep -v '\.drv$' > /tmp/store-path-pre-build`]);
}
// Remember existing store paths
await exec.exec("sh", ["-c", `nix path-info --all | grep -v '\.drv$' > /tmp/store-path-pre-build`]);
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
throw (error);
Expand All @@ -54,10 +54,14 @@ async function setup() {

async function upload() {
try {
if (signingKey !== "" && skipPush !== 'true') {
if (skipPush === 'true') {
core.info('Pushing is disabled as skipPush is set to true');
} else if (signingKey !== "" || authToken !== "") {
core.startGroup('Cachix: pushing paths');
execFileSync(`${__dirname}/push-paths.sh`, [cachixExecutable, name], { stdio: 'inherit' });
core.endGroup();
} else {
core.info('Pushing is disabled as signing key nor auth token are set.');
}
} catch (error) {
core.setFailed(`Action failed with error: ${error}`);
Expand Down

0 comments on commit 38dc1a9

Please sign in to comment.