mirror of
https://github.com/ingress-it-solutions/gitea-code-review-action.git
synced 2025-04-19 18:56:45 +00:00
commit
6cbe295593
4 changed files with 28 additions and 7 deletions
|
@ -22,13 +22,12 @@ inputs:
|
|||
description: 'The maximum code length for the pull request to be sent to OpenAI.'
|
||||
default: 6000
|
||||
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:
|
||||
description: 'Where is the source code located'
|
||||
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}
|
||||
\`\`\`'
|
||||
|
|
13
dist/index.js
vendored
13
dist/index.js
vendored
|
@ -39201,6 +39201,8 @@ function configWithProxy(config) {
|
|||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
// Get input values
|
||||
|
@ -39351,9 +39353,18 @@ async function run() {
|
|||
|
||||
});
|
||||
} 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) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
13
index.js
13
index.js
|
@ -15,6 +15,8 @@ function configWithProxy(config) {
|
|||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
// Get input values
|
||||
|
@ -165,9 +167,18 @@ async function run() {
|
|||
|
||||
});
|
||||
} 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) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue