-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (25 loc) · 959 Bytes
/
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
const path = require('path');
const core = require('@actions/core');
const tc = require('@actions/tool-cache');
const { getDownloadObject } = require('./lib/utils');
async function setup() {
try {
// Get version of tool to be installed
const version = core.getInput('version');
// Download the specific version of the tool, e.g. as a tarball/zipball
const download = await getDownloadObject(version);
const pathToTarball = await tc.downloadTool(download.url);
// Extract the tarball/zipball onto host runner
const extract = download.url.endsWith('.zip') ? tc.extractZip : tc.extractTar;
const pathToCLI = await extract(pathToTarball);
// Expose the tool by adding it to the PATH
core.addPath(path.join(pathToCLI, download.binPath));
core.info(`Successfully setup konjure version ${ version }`);
} catch (e) {
core.setFailed(e);
}
}
module.exports = setup
if (require.main === module) {
setup();
}