mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 17:44:07 +02:00
Allow installing cachix globally for self-hosted runners
This commit is contained in:
parent
b5a076c711
commit
b65c18402a
4 changed files with 5027 additions and 1891 deletions
4613
dist/main/index.js
vendored
4613
dist/main/index.js
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -20,13 +20,15 @@
|
||||||
"author": "Domen Kožar",
|
"author": "Domen Kožar",
|
||||||
"license": "ASL2",
|
"license": "ASL2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.0.1"
|
"@actions/exec": "^1.1.1",
|
||||||
|
"which": "^2.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.13",
|
"@types/jest": "^24.0.13",
|
||||||
"@types/node": "^12.0.4",
|
"@types/node": "^12.0.4",
|
||||||
"@zeit/ncc": "^0.20.5",
|
"@vercel/ncc": "^0.34",
|
||||||
|
"@types/which": "^2.0.1",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.8.0",
|
||||||
"jest-circus": "^24.7.1",
|
"jest-circus": "^24.7.1",
|
||||||
"ts-jest": "^24.0.2",
|
"ts-jest": "^24.0.2",
|
||||||
|
|
|
||||||
12
src/main.ts
12
src/main.ts
|
|
@ -1,6 +1,7 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as coreCommand from '@actions/core/lib/command'
|
import * as coreCommand from '@actions/core/lib/command'
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import which from 'which';
|
||||||
|
|
||||||
export const IsPost = !!process.env['STATE_isPost']
|
export const IsPost = !!process.env['STATE_isPost']
|
||||||
|
|
||||||
|
|
@ -12,7 +13,6 @@ const authToken = core.getInput('authToken')
|
||||||
const skipPush = core.getInput('skipPush');
|
const skipPush = core.getInput('skipPush');
|
||||||
const pathsToPush = core.getInput('pathsToPush');
|
const pathsToPush = core.getInput('pathsToPush');
|
||||||
const pushFilter = core.getInput('pushFilter');
|
const pushFilter = core.getInput('pushFilter');
|
||||||
const cachixExecutable = process.env.HOME + '/.nix-profile/bin/cachix';
|
|
||||||
const cachixArgs = core.getInput('cachixArgs');
|
const cachixArgs = core.getInput('cachixArgs');
|
||||||
const installCommand =
|
const installCommand =
|
||||||
core.getInput('installCommand') ||
|
core.getInput('installCommand') ||
|
||||||
|
|
@ -20,13 +20,19 @@ const installCommand =
|
||||||
|
|
||||||
async function setup() {
|
async function setup() {
|
||||||
try {
|
try {
|
||||||
|
if(!which.sync('cachix', { nothrow: true })) {
|
||||||
core.startGroup('Cachix: installing')
|
core.startGroup('Cachix: installing')
|
||||||
await exec.exec('bash', ['-c', installCommand]);
|
await exec.exec('bash', ['-c', installCommand]);
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
}
|
||||||
|
|
||||||
|
core.startGroup('Cachix: checking version')
|
||||||
|
await exec.exec('cachix', ['--version']);
|
||||||
|
core.endGroup()
|
||||||
|
|
||||||
// for managed signing key and private caches
|
// for managed signing key and private caches
|
||||||
if (authToken !== "") {
|
if (authToken !== "") {
|
||||||
await exec.exec(cachixExecutable, ['authtoken', authToken]);
|
await exec.exec('cachix', ['authtoken', authToken]);
|
||||||
}
|
}
|
||||||
|
|
||||||
core.startGroup(`Cachix: using cache ` + name);
|
core.startGroup(`Cachix: using cache ` + name);
|
||||||
|
|
@ -59,7 +65,7 @@ async function upload() {
|
||||||
if (skipPush === 'true') {
|
if (skipPush === 'true') {
|
||||||
core.info('Pushing is disabled as skipPush is set to true');
|
core.info('Pushing is disabled as skipPush is set to true');
|
||||||
} else if (signingKey !== "" || authToken !== "") {
|
} 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 {
|
} else {
|
||||||
core.info('Pushing is disabled as signingKey nor authToken are set (or are empty?) in your YAML file.');
|
core.info('Pushing is disabled as signingKey nor authToken are set (or are empty?) in your YAML file.');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue