-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 923 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
32
33
const path = require('path');
const fs = require('fs');
const io = require('@actions/io');
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', { required: true });
// Download the specific version of the tool
const download = getDownloadObject(version);
const pathToCLI = await tc.downloadTool(download.url);
// Expose the tool by adding it to the PATH
const target = pathToCLI + '.bin'
const targetCLI = path.join(target, 'terraform-backend-git')
await io.mkdirP(target)
await io.mv(pathToCLI, targetCLI);
fs.chmodSync(targetCLI, "777");
core.addPath(target);
} catch (e) {
core.setFailed(e);
}
}
module.exports = setup
if (require.main === module) {
setup();
}