Skip to content

Commit 0809899

Browse files
authored
Create issue_response.yaml
added automatic issue checks using gemini
1 parent 64e5862 commit 0809899

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/issue_response.yaml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Auto PR Description with Gemini
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited]
6+
7+
jobs:
8+
generate-pr-description:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Code
12+
uses: actions/checkout@v3
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.10'
18+
19+
- name: Install Dependencies
20+
run: pip install google-generativeai
21+
22+
- name: Generate PR Description with Gemini
23+
env:
24+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
25+
PR_BODY: ${{ github.event.pull_request.body }}
26+
run: |
27+
python <<EOF
28+
import google.generativeai as genai
29+
import os
30+
31+
genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
32+
model = genai.GenerativeModel("gemini-pro")
33+
34+
pr_body = os.getenv("PR_BODY", "No description provided.")
35+
prompt = f"Improve this GitHub PR description:\n\n{pr_body}"
36+
response = model.generate_content(prompt)
37+
38+
with open("pr_description.txt", "w") as f:
39+
f.write(response.text)
40+
41+
print("Generated PR Description:", response.text)
42+
EOF
43+
44+
- name: Update PR Description
45+
uses: actions/github-script@v6
46+
with:
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
script: |
49+
const fs = require('fs');
50+
const description = fs.readFileSync('pr_description.txt', 'utf8');
51+
github.rest.pulls.update({
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
pull_number: context.payload.pull_request.number,
55+
body: description
56+
});
57+

0 commit comments

Comments
 (0)