-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.js
More file actions
33 lines (21 loc) · 945 Bytes
/
comment.js
File metadata and controls
33 lines (21 loc) · 945 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
const github = require('@actions/github');
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;
const octokit = github.getOctokit(GITHUB_TOKEN);
const comment = async(context, data) => {
const errorMessage = `
An unknown error occurred.
Please try again later.And make sure the number of files that are changed is 1
Please make sure the body of the pull request follows the correct format:
Example:
Language: py (required and allowed languages are: java, py, cpp, c, go, cs, js)
Input: (optional can be left black like how it is done in this example.)
`;
const commentBody = data.message === 'Success' ? data.output : errorMessage;
await octokit.rest.issues.createComment({
owner: context.repo().owner,
repo: context.repo().repo,
issue_number: context.payload.pull_request.number,
body: commentBody
});
}
module.exports=comment;