Skip to content

Commit 1706fde

Browse files
committed
Use nodejs like a pro.
1 parent 04d8448 commit 1706fde

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

.github/scripts/pr_comment.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Update the content of the existing comment.
77
88
https://octokit.github.io/rest.js/v19
99
*/
10-
module.exports = async ({octokit_rest, context, process}) => {
10+
module.exports = async ({github, context, process}) => {
11+
var octokit_rest = github
1112
if (context.eventName != "pull_request") {
1213
// Only PR are supported.
1314
return
@@ -24,21 +25,25 @@ module.exports = async ({octokit_rest, context, process}) => {
2425
*/
2526
var doAction = async function() {
2627

28+
console.log(context)
29+
2730
fs = require('fs');
28-
var body = fs.readFile(
29-
process.env.GITHUB_WORKSPACE + "/" + process.env.COMMENT_BODY)
3031

31-
var comments = await octokit.rest.issues.listComments({
32+
const body = fs.readFileSync(
33+
process.env.GITHUB_WORKSPACE + "/" + process.env.COMMENT_BODY, 'utf8');
34+
35+
var comments = await octokit_rest.issues.listComments({
3236
owner: context.repo.owner,
3337
repo: context.repo.repo,
34-
issue_number: context.event.number,
38+
issue_number: context.payload.number,
3539
})
40+
3641
console.log(comments)
3742

3843
await octokit_rest.issues.createComment({
3944
owner: context.repo.owner,
4045
repo: context.repo.repo,
41-
issue_number: context.event.number,
46+
issue_number: context.payload.number,
4247
body: body,
4348
})
4449

0 commit comments

Comments
 (0)