-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (35 loc) · 1.63 KB
/
index.js
File metadata and controls
46 lines (35 loc) · 1.63 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
39
40
41
42
43
44
45
46
const core = require('@actions/core');
const exec = require('@actions/exec');
const _ = require('lodash');
async function run() {
try {
let workspace = process.env.GITHUB_WORKSPACE;
let currentRunnerID = process.env.GITHUB_RUN_ID;
let repoUrl = "https://github.com/" + process.env.GITHUB_REPOSITORY + ".git";
let ref = process.env.GITHUB_REF;
let token = core.getInput('token');
let mode = core.getInput('mode');
let api_url = core.getInput('api_url');
let instance_url = core.getInput('instance_url');
let docker_name = "qualityclouds/pipeline-servicenow";
let branch = ref.replace("refs/heads/", "")
if(mode == null) mode = "local";
let api_url_param= "";
if(api_url != null && api_url != "") api_url_param = `-e API_URL=${api_url}`;
console.log('starting the scan');
console.log('github run id :' + currentRunnerID);
// console.log('mode :' + mode);
console.log('instance_url :' + instance_url);
// console.log('branch :' + branch);
await exec.exec(`docker pull ${docker_name} -q`);
let command = (`docker run --user root -v ${workspace}:/src/:rw --network="host" ${api_url_param} -e REPO_URL=${repoUrl} -e QC_API_KEY=${token} -e diff_mode="1" -e MODE=${mode} -e INSTANCE_URL=${instance_url} -e BRANCH=${branch} -t ${docker_name} snow-scan`);
try {
await exec.exec(command);
} catch (err) {
core.setFailed('failed to scan the target: ' + err.toString());
}
} catch (error) {
core.setFailed(error.message);
}
}
run();