-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
39 lines (34 loc) · 1.21 KB
/
main.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
33
34
35
36
37
38
39
const os = require('os');
const path = require('path');
const core = require('@actions/core');
const tc = require('@actions/tool-cache');
const exec = require('@actions/exec');
function getDownloadURL(version) {
const platform = os.platform();
const filename = `datasubst-${version}-${platform}-amd64`
const url = `https://github.com/marcelocarlos/datasubst/releases/download/${version}/${filename}.tar.gz`;
core.info(`Downloading from ${url}`);
return url
}
async function setup() {
try {
const version = core.getInput('version');
core.info(`Installing datasubst ${version}...`);
const download = getDownloadURL(version);
const pathToTarball = await tc.downloadTool(download);
core.info(`Downloaded, extracting...`);
const pathToCLI = await tc.extractTar(pathToTarball);
core.info(`Extracted to ${pathToCLI}`);
core.addPath(path.join(pathToCLI, 'datasubst'));
core.info(`Added ${pathToCLI} to the PATH`);
// run datasubst --version just to make sure it's available
await exec.exec('datasubst --version');
core.info('>>> Successfully invoked datasubst help');
} catch (e) {
core.setFailed(e);
}
}
module.exports = setup
if (require.main === module) {
setup();
}