forked from peter-evans/commit-comment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (32 loc) · 924 Bytes
/
index.js
File metadata and controls
36 lines (32 loc) · 924 Bytes
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
const { inspect } = require("util");
const core = require("@actions/core");
const { request } = require("@octokit/request");
async function run() {
try {
const inputs = {
token: core.getInput("token"),
sha: core.getInput("sha"),
body: core.getInput("body"),
path: core.getInput("path"),
position: core.getInput("position")
};
core.debug(`Inputs: ${inspect(inputs)}`);
const sha = inputs.sha ? inputs.sha : process.env.GITHUB_SHA;
core.debug(`SHA: ${sha}`);
await request(
`POST /repos/${process.env.GITHUB_REPOSITORY}/commits/${sha}/comments`,
{
headers: {
authorization: `token ${inputs.token}`
},
body: eval('`'+inputs.body+'`'),
path: `${inputs.path}`,
position: `${inputs.position}`
}
);
} catch (error) {
core.debug(inspect(error));
core.setFailed(error.message);
}
}
run();