Skip to content

Commit

Permalink
Use nodejs like a pro.
Browse files Browse the repository at this point in the history
  • Loading branch information
adiroiban committed Nov 4, 2022
1 parent 04d8448 commit 1706fde
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions .github/scripts/pr_comment.js
Expand Up @@ -7,7 +7,8 @@ Update the content of the existing comment.
https://octokit.github.io/rest.js/v19
*/
module.exports = async ({octokit_rest, context, process}) => {
module.exports = async ({github, context, process}) => {
var octokit_rest = github
if (context.eventName != "pull_request") {
// Only PR are supported.
return
Expand All @@ -24,21 +25,25 @@ module.exports = async ({octokit_rest, context, process}) => {
*/
var doAction = async function() {

console.log(context)

fs = require('fs');
var body = fs.readFile(
process.env.GITHUB_WORKSPACE + "/" + process.env.COMMENT_BODY)

var comments = await octokit.rest.issues.listComments({
const body = fs.readFileSync(
process.env.GITHUB_WORKSPACE + "/" + process.env.COMMENT_BODY, 'utf8');

var comments = await octokit_rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.event.number,
issue_number: context.payload.number,
})

console.log(comments)

await octokit_rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.event.number,
issue_number: context.payload.number,
body: body,
})

Expand Down

0 comments on commit 1706fde

Please sign in to comment.