Merge pull request #12 from ingress-it-solutions/dev

Dev
This commit is contained in:
vandanafuletra 2023-04-23 16:53:07 +05:30 committed by GitHub
commit 6cbe295593
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 7 deletions

View file

@ -22,13 +22,12 @@ inputs:
description: 'The maximum code length for the pull request to be sent to OpenAI.' description: 'The maximum code length for the pull request to be sent to OpenAI.'
default: 6000 default: 6000
type: int type: int
PROMPT_TEMPLATE:
description: 'The template for the FULL_REVIEW_COMMENT prompt.'
default: 'Please analyze the pull request''s code and inform me whether it requires optimization, and provide an explanation for your decision:
SOURCE_AT: SOURCE_AT:
description: 'Where is the source code located' description: 'Where is the source code located'
default: 'github' default: 'github'
PROMPT_TEMPLATE:
description: 'The template for the FULL_REVIEW_COMMENT prompt.'
default: 'Please analyze the pull request''s code and inform me whether it requires optimization, and provide an explanation for your decision:
\`\`\` \`\`\`
${code} ${code}
\`\`\`' \`\`\`'

13
dist/index.js vendored
View file

@ -39201,6 +39201,8 @@ function configWithProxy(config) {
return c; return c;
} }
async function run() { async function run() {
try { try {
// Get input values // Get input values
@ -39351,9 +39353,18 @@ async function run() {
}); });
} else if (sourceAt === 'gitea') } else if (sourceAt === 'gitea')
{ {
const comment = answerTemplate.replace('${answer}', answer);
// Make a POST request to create a comment on a pull request
const createCommentOnPullRequest = async (repoOwner, repoName, prNumber, comment) => {
const url = `${githubBaseURL}/repos/${repoOwner}/${repoName}/issues/${prNumber}/comments`;
const headers = { 'Authorization': `token ${githubToken}` };
const data = { 'body': comment };
await axios.post(url, data, { headers });
} }
await createCommentOnPullRequest(repoOwner, repoName, prNumber, comment);
}
} 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

@ -15,6 +15,8 @@ function configWithProxy(config) {
return c; return c;
} }
async function run() { async function run() {
try { try {
// Get input values // Get input values
@ -165,9 +167,18 @@ async function run() {
}); });
} else if (sourceAt === 'gitea') } else if (sourceAt === 'gitea')
{ {
const comment = answerTemplate.replace('${answer}', answer);
// Make a POST request to create a comment on a pull request
const createCommentOnPullRequest = async (repoOwner, repoName, prNumber, comment) => {
const url = `${githubBaseURL}/repos/${repoOwner}/${repoName}/issues/${prNumber}/comments`;
const headers = { 'Authorization': `token ${githubToken}` };
const data = { 'body': comment };
await axios.post(url, data, { headers });
} }
await createCommentOnPullRequest(repoOwner, repoName, prNumber, comment);
}
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }