-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (40 loc) · 1.36 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const core = require('@actions/core')
const simpletGit = require('simple-git')
const shell = require('shelljs')
const fs = require('fs');
const git = simpletGit.default()
run()
async function run() {
try {
const configFiles = core.getInput('configFiles');
const outputFolder = core.getInput('outputFolder');
const genericRules = core.getInput('genericRules');
if (!fs.existsSync(outputFolder)) {
fs.mkdirSync(outputFolder);
}
await buildPyrra()
const { stderr, code } = shell.exec(`/tmp/pyrra/pyrra generate --config-files="${configFiles}" --prometheus-folder="${outputFolder}" --generic-rules="${genericRules}"`)
if (code != 0) {
core.setFailed(stderr)
}
} catch (error) {
core.setFailed(error.message);
}
}
async function buildPyrra() {
const repo = 'https://github.com/pyrra-dev/pyrra';
const clonePath = '/tmp/pyrra';
try {
console.log("Cloning Pyrra repository")
await git.clone(repo, clonePath)
console.log('Cloning succesful');
console.log("Building binary")
shell.cd(clonePath)
const { code } = shell.exec('make ui/node_modules ui/build build', { silent: true })
if (code == 0) {
console.log('Build succesful');
}
} catch (err) {
console.log(err)
}
}