So I am really lost in JS world and I will appreciate all the help I can get. What I am trying to do is to use a github action to update a Pull Request comment or create one. I have combined a lot of stuff in the following script and I can not resolve the error at the bottom. I know it is Syntax one, but belive me I am not sure how to read the error msg at all. I would love someone to point me at what line to look
Run actions/github-script@v6
with:
github-token: ***
script: const fs = require("fs");
const plan = fs.readFileSync("/tmp/plan.txt", {encoding: 'utf-8'});
const maxGitHubBodyCharacters = 65536;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
function chunkSubstr(str, size) {
const numChunks = Math.ceil(str.length / size)
const chunks = new Array(numChunks)
for (let i = 0, o = 0; i < numChunks; i, o = size) {
chunks[i] = str.substr(o, size)
}
return chunks
}
function findBotComment(num) {
const botComment = comments.find(comment => {
comment.user.type === 'Bot' && comment.body.includes('Part # ' ${num})
})
return botComment
}
// Split the Terraform plan into chunks if it's too big and can't fit into the GitHub Action
var plans = chunkSubstr(plan, maxGitHubBodyCharacters);
for (let i = 0; i < plans.length; i ) {
var botC = findBotComment(i);
const output = `### Part # ${i 1}
#### Terraform Format and Style