-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 1.15 KB
/
index.js
File metadata and controls
38 lines (32 loc) · 1.15 KB
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
const path = require("path");
const os = require("os");
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");
// install dir for sst
const installDir = path.join(os.homedir(), ".sst", "bin");
// Download the specific version of the tool, e.g. as a tarball/zipball
const download = getDownloadObject(version);
console.log(`Downloading ${download.url}`);
const pathToTarball = await tc.downloadTool(download.url);
console.log(`Downloaded tarball to ${pathToTarball}`);
// Extract the tarball/zipball onto host runner
const extract = tc.extractTar;
const pathToCLI = await extract(pathToTarball, installDir, "xz");
console.log(`Extracted tarball to ${pathToCLI}`);
const sstPath = pathToCLI;
// Expose the tool by adding it to the PATH
core.addPath(sstPath);
console.log(`Added ${sstPath} to PATH`);
} catch (e) {
core.setFailed(e);
}
}
module.exports = setup;
if (require.main === module) {
setup();
}