Using @actions/github

This commit is contained in:
Bhavik MacBook PRO 16 2023-04-05 23:51:03 +05:30
parent 7d5b853474
commit 52b842f210
3 changed files with 17 additions and 33 deletions

24
dist/index.js vendored
View file

@ -39298,25 +39298,17 @@ async function run() {
core.debug(`openai response: ${answer}`); core.debug(`openai response: ${answer}`);
// Reply to the review comment with the OpenAI response // Reply to the review comment with the OpenAI response
const octokit = github.getOctokit(githubToken, { const client = new github.GitHub(githubToken, {
baseUrl: githubBaseURL baseUrl: githubBaseURL
}); });
const commentUrl = `${githubBaseURL}/repos/${repoOwner}/${repoName}/pulls/${prNumber}`;
var response = await axios.post(commentUrl, { await client.issues.createComment({
body: answerTemplate.replace('${answer}', answer), owner: repoOwner,
headers: { repo: repoName,
Authorization: `Bearer ${githubToken}` issue_number: prNumber,
} body: answerTemplate.replace('${answer}', answer)
}); });
const output = response.data;
core.debug(`Output Values: ${output}`);
// await octokit.rest.issues.createComment({
// owner: repoOwner,
// repo: repoName,
// issue_number: prNumber,
// body: answerTemplate.replace('${answer}', answer)
// // in_reply_to: comment.id
// });
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -112,25 +112,17 @@ async function run() {
core.debug(`openai response: ${answer}`); core.debug(`openai response: ${answer}`);
// Reply to the review comment with the OpenAI response // Reply to the review comment with the OpenAI response
const octokit = github.getOctokit(githubToken, { const client = new github.GitHub(githubToken, {
baseUrl: githubBaseURL baseUrl: githubBaseURL
}); });
const commentUrl = `${githubBaseURL}/repos/${repoOwner}/${repoName}/pulls/${prNumber}`;
var response = await axios.post(commentUrl, { await client.issues.createComment({
body: answerTemplate.replace('${answer}', answer), owner: repoOwner,
headers: { repo: repoName,
Authorization: `Bearer ${githubToken}` issue_number: prNumber,
} body: answerTemplate.replace('${answer}', answer)
}); });
const output = response.data;
core.debug(`Output Values: ${output}`);
// await octokit.rest.issues.createComment({
// owner: repoOwner,
// repo: repoName,
// issue_number: prNumber,
// body: answerTemplate.replace('${answer}', answer)
// // in_reply_to: comment.id
// });
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }