-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
29 lines (23 loc) · 995 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
const core = require("@actions/core");
const github = require("@actions/github");
const execa = require("execa");
const fs = require("fs");
const cloc = require("./src/cloc");
const comment = require("./src/comment");
const report = require("./src/report");
const start = async () => {
const github_token = core.getInput("GITHUB_TOKEN", { required: true });
const options = core.getInput("options", { required: true });
const context = github.context;
const event = context.eventName;
/* run the cloc command against the codebase , action checkout is needed */
cloc.run_command(options);
/* getting the data to be commented on the thread */
const report_data = report.parse();
/* getting the thread number, pr and pr_target only, avoiding issues */
if (event === "pull_request" || event === "pull_request_target") {
const thread_number = context.payload.pull_request.number;
await comment.send(context, github_token, thread_number, report_data);
}
};
start();