-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (27 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const core = require('@actions/core');
const tc = require('@actions/tool-cache');
const exec = require('@actions/exec');
async function setup() {
try {
// Get version of tool to be installed
let version = core.getInput('version') || 'latest';
let downloadUrl = `https://github.com/polyseam/cndi/releases/${version}/download/cndi-linux.tar.gz`;
if(version === 'main'){
downloadUrl = `https://cndi-binaries.s3.amazonaws.com/cndi/main/cndi-linux.tar.gz`;
}
// Download the specific version of the tool, e.g. as a tarball/zipball
const pathToTar = await tc.downloadTool(downloadUrl, `/home/runner/.cndi/bin.tar`);
const pathToBin = await tc.extractTar(pathToTar,`/home/runner/.cndi/bin`);
core.debug(`Downloaded tool to ${pathToBin}`);
core.addPath(pathToBin)
core.debug(`Added ${pathToBin} to PATH`);
exec.exec(`chmod +x ${pathToBin}`);
core.debug('Set cndi to be executable');
} catch (e) {
core.setFailed(e);
}
}
module.exports = setup
if (require.main === module) {
setup();
}