CI: Issue Change Requests
This commit is contained in:
@@ -86,14 +86,15 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(reviews) > 0 {
|
if len(reviews) > 0 {
|
||||||
commentBody := "### 🤖 Gemini Writing Review\n\n" + strings.Join(reviews, "\n\n---\n\n")
|
reviewBody := "### 🤖 Gemini Writing Review\n\n" + strings.Join(reviews, "\n\n---\n\n")
|
||||||
_, _, err = client.CreateIssueComment(owner, repo, prNumber, gitea.CreateIssueCommentOption{
|
_, _, err = client.CreatePullReview(owner, repo, prNumber, gitea.CreatePullReviewOptions{
|
||||||
Body: commentBody,
|
State: gitea.ReviewStateRequestChanges,
|
||||||
|
Body: reviewBody,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to post PR comment: %v", err)
|
log.Fatalf("Failed to create PR review: %v", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Successfully posted review comments.")
|
fmt.Println("Successfully created PR change request review.")
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("No Markdown files to review or no suggestions found.")
|
fmt.Println("No Markdown files to review or no suggestions found.")
|
||||||
}
|
}
|
||||||
@@ -116,11 +117,13 @@ func readFile(path string) (string, error) {
|
|||||||
func getGeminiReview(ctx context.Context, model *genai.GenerativeModel, content string) (string, error) {
|
func getGeminiReview(ctx context.Context, model *genai.GenerativeModel, content string) (string, error) {
|
||||||
prompt := fmt.Sprintf(`
|
prompt := fmt.Sprintf(`
|
||||||
Review the following Markdown content for spelling errors, grammar mistakes, and style improvements.
|
Review the following Markdown content for spelling errors, grammar mistakes, and style improvements.
|
||||||
|
This review will be posted as a "Request Changes" on a Pull Request, so please be specific and actionable.
|
||||||
Provide your feedback as a list of bullet points. For each point:
|
Provide your feedback as a list of bullet points. For each point:
|
||||||
1. Identify the issue.
|
1. Identify the issue.
|
||||||
2. Provide the original text.
|
2. Provide the original text snippet.
|
||||||
3. Suggest an alternative or fix.
|
3. Suggest a clear alternative or fix.
|
||||||
4. Check the content on completeness and correctness.
|
4. Briefly explain why the change is necessary if not obvious.
|
||||||
|
5. Check the content for completeness and technical correctness.
|
||||||
|
|
||||||
Content:
|
Content:
|
||||||
%s
|
%s
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ func main() {
|
|||||||
repoFullName := os.Getenv("GITHUB_REPOSITORY")
|
repoFullName := os.Getenv("GITHUB_REPOSITORY")
|
||||||
prNumberStr := os.Getenv("PR_NUMBER")
|
prNumberStr := os.Getenv("PR_NUMBER")
|
||||||
|
|
||||||
if token == "" || prNumberStr == "" {
|
if token == "" || repoFullName == "" || prNumberStr == "" {
|
||||||
log.Fatal("Missing required environment variables: GEMINI_API_KEY, GITEA_TOKEN, GITHUB_REPOSITORY, PR_NUMBER")
|
log.Fatal("Missing required environment variables: GITEA_TOKEN, GITHUB_REPOSITORY, PR_NUMBER")
|
||||||
}
|
}
|
||||||
|
|
||||||
if baseURL == "" {
|
if baseURL == "" {
|
||||||
@@ -65,7 +65,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(counts) > 0 {
|
if len(counts) > 0 {
|
||||||
commentBody := "### 🤖 Gemini Writing Review\n\n" + strings.Join(counts, "\n\n---\n\n")
|
commentBody := "### 🤖 Word Count Report\n\n" + strings.Join(counts, "\n\n---\n\n")
|
||||||
_, _, err = client.CreateIssueComment(owner, repo, prNumber, gitea.CreateIssueCommentOption{
|
_, _, err = client.CreateIssueComment(owner, repo, prNumber, gitea.CreateIssueCommentOption{
|
||||||
Body: commentBody,
|
Body: commentBody,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user