mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 17:44:07 +02:00
Merge pull request #38 from numtide/embed-node-modules
Embed node modules
This commit is contained in:
commit
90e72ecbb7
7 changed files with 2151 additions and 886 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -91,3 +91,6 @@ typings/
|
|||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# Skip the lib folder
|
||||
lib/
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ branding:
|
|||
icon: 'database'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/main.js'
|
||||
main: 'dist/main/index.js'
|
||||
|
|
|
|||
1640
dist/main/index.js
vendored
Normal file
1640
dist/main/index.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
79
lib/main.js
79
lib/main.js
|
|
@ -1,79 +0,0 @@
|
|||
"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 strings_1 = require("./strings");
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
// inputs
|
||||
const name = core.getInput('name', { required: true });
|
||||
const file = core.getInput('file');
|
||||
const skipNixBuild = core.getInput('skipNixBuild');
|
||||
const attributes = core.getInput('attributes');
|
||||
const nixBuildArgs = core.getInput('nixBuildArgs');
|
||||
const signingKey = core.getInput('signingKey');
|
||||
const authToken = core.getInput('authToken');
|
||||
const cachixExecutable = "/nix/var/nix/profiles/per-user/runner/profile/bin/cachix";
|
||||
core.startGroup('Cachix: installing');
|
||||
yield exec.exec('nix-env', ['-iA', 'cachix', '-f', 'https://cachix.org/api/v1/install']);
|
||||
core.endGroup();
|
||||
// for private caches
|
||||
if (authToken !== "") {
|
||||
yield exec.exec(cachixExecutable, ['authtoken', authToken]);
|
||||
}
|
||||
core.startGroup(`Cachix: using ` + name);
|
||||
yield exec.exec('cachix', ['use', name]);
|
||||
core.endGroup();
|
||||
if (signingKey !== "") {
|
||||
core.exportVariable('CACHIX_SIGNING_KEY', signingKey);
|
||||
}
|
||||
if (skipNixBuild !== 'true') {
|
||||
const args = strings_1.prependEach('-A', strings_1.nonEmptySplit(attributes, /\s+/)).concat([file || "default.nix"]);
|
||||
const additionalArgs = strings_1.nonEmptySplit(nixBuildArgs, /\s+/);
|
||||
const allArgs = additionalArgs.concat(args);
|
||||
core.startGroup(`nix-build {allArgs.join(' ')}`);
|
||||
if (signingKey !== "") {
|
||||
// Remember existing store paths
|
||||
yield exec.exec("sh", ["-c", `nix path-info --all | grep -v '\.drv$' > store-path-pre-build`]);
|
||||
}
|
||||
let paths = '';
|
||||
const options = {
|
||||
listeners: {
|
||||
stdout: (data) => {
|
||||
paths += data.toString();
|
||||
},
|
||||
}
|
||||
};
|
||||
yield exec.exec('nix-build', allArgs, options);
|
||||
core.endGroup();
|
||||
if (signingKey !== "") {
|
||||
core.startGroup('Cachix: pushing paths');
|
||||
yield exec.exec("sh", ["-c", `nix path-info --all | grep -v '\.drv$' | cat - store-path-pre-build | sort | uniq -u | ${cachixExecutable} push ${name}`]);
|
||||
core.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`Action failed with error: ${error}`);
|
||||
throw (error);
|
||||
}
|
||||
});
|
||||
}
|
||||
run();
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function prependEach(elem, array) {
|
||||
const init = [];
|
||||
return array.reduce((r, a) => r.concat(elem, a), init);
|
||||
}
|
||||
exports.prependEach = prependEach;
|
||||
;
|
||||
function nonEmptySplit(str, separator) {
|
||||
return str.split(separator).filter(word => word != "");
|
||||
}
|
||||
exports.nonEmptySplit = nonEmptySplit;
|
||||
10
package.json
10
package.json
|
|
@ -3,9 +3,9 @@
|
|||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "nix-build with the help of caching to Cachix",
|
||||
"main": "lib/main.js",
|
||||
"main": "dist/main/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "tsc && ncc build -o dist/main src/main.ts",
|
||||
"test": "jest"
|
||||
},
|
||||
"repository": {
|
||||
|
|
@ -21,16 +21,16 @@
|
|||
"license": "ASL2",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.1.0",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/tool-cache": "^1.1.2"
|
||||
"@actions/exec": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-node": "^8.4.1",
|
||||
"@types/jest": "^24.0.13",
|
||||
"@types/node": "^12.0.4",
|
||||
"@zeit/ncc": "^0.20.5",
|
||||
"jest": "^24.8.0",
|
||||
"jest-circus": "^24.7.1",
|
||||
"ts-jest": "^24.0.2",
|
||||
"ts-node": "^8.4.1",
|
||||
"typescript": "^3.5.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue