mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 17:44:07 +02:00
Initial commit
This commit is contained in:
commit
a6de7cd0c2
14 changed files with 4063 additions and 0 deletions
52
lib/main.js
Normal file
52
lib/main.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const utils_1 = require("./utils");
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const file = core.getInput('file');
|
||||
const attributes = core.getInput('attributes');
|
||||
const cachixPush = core.getInput('cachixPush', { required: true });
|
||||
console.log(`Installing Cachix ...`);
|
||||
yield exec.exec('nix-env', ['-iA', 'cachix', '-f', 'https://cachix.org/api/v1/install']);
|
||||
// TODO: cachix watch
|
||||
console.log(`Setting up cache ` + cachixPush + `...`);
|
||||
yield exec.exec('cachix', ['use', cachixPush]);
|
||||
console.log(`Invoking nix-build...`);
|
||||
let paths = '';
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
paths += data.toString();
|
||||
},
|
||||
}
|
||||
};
|
||||
const args = ['-f', file || "default.nix"].concat(utils_1.extrasperse('-A', attributes.split(/\s/)));
|
||||
yield exec.exec('nix-build', args, options);
|
||||
console.log(`Pushing to cache ` + cachixPush + `...`);
|
||||
yield exec.exec('cachix', ['push', cachixPush].concat(paths.split(/\s/).join(' ')));
|
||||
});
|
||||
}
|
||||
try {
|
||||
run();
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
8
lib/utils.js
Normal file
8
lib/utils.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function extrasperse(elem, array) {
|
||||
const init = [];
|
||||
return array.reduce((r, a) => r.concat(elem, a), init);
|
||||
}
|
||||
exports.extrasperse = extrasperse;
|
||||
;
|
||||
Loading…
Add table
Add a link
Reference in a new issue