Allow installing cachix globally for self-hosted runners

This commit is contained in:
Domen Kožar 2022-10-11 16:04:33 +01:00
commit b65c18402a
4 changed files with 5027 additions and 1891 deletions

4629
dist/main/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -20,13 +20,15 @@
"author": "Domen Kožar",
"license": "ASL2",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.1"
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"which": "^2.0.2"
},
"devDependencies": {
"@types/jest": "^24.0.13",
"@types/node": "^12.0.4",
"@zeit/ncc": "^0.20.5",
"@vercel/ncc": "^0.34",
"@types/which": "^2.0.1",
"jest": "^24.8.0",
"jest-circus": "^24.7.1",
"ts-jest": "^24.0.2",

View file

@ -1,6 +1,7 @@
import * as core from '@actions/core';
import * as coreCommand from '@actions/core/lib/command'
import * as exec from '@actions/exec';
import which from 'which';
export const IsPost = !!process.env['STATE_isPost']
@ -12,7 +13,6 @@ const authToken = core.getInput('authToken')
const skipPush = core.getInput('skipPush');
const pathsToPush = core.getInput('pathsToPush');
const pushFilter = core.getInput('pushFilter');
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
const cachixArgs = core.getInput('cachixArgs');
const installCommand =
core.getInput('installCommand') ||
@ -20,13 +20,19 @@ const installCommand =
async function setup() {
try {
core.startGroup('Cachix: installing')
await exec.exec('bash', ['-c', installCommand]);
if(!which.sync('cachix', { nothrow: true })) {
core.startGroup('Cachix: installing')
await exec.exec('bash', ['-c', installCommand]);
core.endGroup()
}
core.startGroup('Cachix: checking version')
await exec.exec('cachix', ['--version']);
core.endGroup()
// for managed signing key and private caches
if (authToken !== "") {
await exec.exec(cachixExecutable, ['authtoken', authToken]);
await exec.exec('cachix', ['authtoken', authToken]);
}
core.startGroup(`Cachix: using cache ` + name);
@ -59,7 +65,7 @@ async function upload() {
if (skipPush === 'true') {
core.info('Pushing is disabled as skipPush is set to true');
} else if (signingKey !== "" || authToken !== "") {
await exec.exec(`${__dirname}/push-paths.sh`, [cachixExecutable, cachixArgs, name, pathsToPush, pushFilter]);
await exec.exec(`${__dirname}/push-paths.sh`, ['cachix', cachixArgs, name, pathsToPush, pushFilter]);
} else {
core.info('Pushing is disabled as signingKey nor authToken are set (or are empty?) in your YAML file.');
}

1551
yarn.lock

File diff suppressed because it is too large Load diff