-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.js
39 lines (30 loc) · 1.03 KB
/
action.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
const core= require('@actions/core');
const github = require('@actions/github');
const { checkUrl, checkHeaders, presentData } = require('./helpers');
try{
const givenUrl= core.getInput('url');
console.log(`Using ${givenUrl}!`);
start(givenUrl);
} catch(error)
{
core.setFailed(error.message);
}
// Calls on helpers.js functions, and creates a PR comment for GitHub
async function start(targetUrl){
checkUrl(targetUrl);
var result = await checkHeaders(targetUrl);
var presentableResult = presentData(result);
console.log(presentableResult);
var comment = "";
console.log(presentableResult.length);
if (presentableResult == 0){
comment = "# Congrats! Looks like all your headers are set correctly!"
} else{
comment = "# Oh no! Found issues with the headers of your website :( \n"
for (i in presentableResult){
comment = comment.concat("- " + presentableResult[i]) + "\n";
}
}
console.log(comment);
core.setOutput("header-issues", comment);
}