mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-04 04:40:38 +08:00
Github custom action development - WIP
This commit is contained in:
6
.github/workflows/review.yaml
vendored
6
.github/workflows/review.yaml
vendored
@ -8,6 +8,6 @@ jobs:
|
|||||||
- name: PR Agent action step
|
- name: PR Agent action step
|
||||||
id: pragent
|
id: pragent
|
||||||
uses: Codium-ai/pr-agent@feature/github_action
|
uses: Codium-ai/pr-agent@feature/github_action
|
||||||
with:
|
env:
|
||||||
openai-key: "TBD: openai key"
|
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
|
||||||
|
OPENAI_ORG: ${{ secrets.OPENAI_ORG }}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from pr_agent.config_loader import settings
|
||||||
|
from pr_agent.tools.pr_reviewer import PRReviewer
|
||||||
|
|
||||||
|
|
||||||
def run_action():
|
def run_action():
|
||||||
GITHUB_EVENT_NAME = os.environ.get('GITHUB_EVENT_NAME', None)
|
GITHUB_EVENT_NAME = os.environ.get('GITHUB_EVENT_NAME', None)
|
||||||
@ -12,22 +15,32 @@ def run_action():
|
|||||||
print("GITHUB_EVENT_PATH not set")
|
print("GITHUB_EVENT_PATH not set")
|
||||||
return
|
return
|
||||||
event_payload = json.load(open(GITHUB_EVENT_PATH, 'r'))
|
event_payload = json.load(open(GITHUB_EVENT_PATH, 'r'))
|
||||||
GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY', None)
|
|
||||||
if not GITHUB_REPOSITORY:
|
|
||||||
print("GITHUB_REPOSITORY not set")
|
|
||||||
return
|
|
||||||
RUNNER_DEBUG = os.environ.get('RUNNER_DEBUG', None)
|
RUNNER_DEBUG = os.environ.get('RUNNER_DEBUG', None)
|
||||||
if not RUNNER_DEBUG:
|
if not RUNNER_DEBUG:
|
||||||
print("RUNNER_DEBUG not set")
|
print("RUNNER_DEBUG not set")
|
||||||
|
OPENAI_KEY = os.environ.get('OPENAI_KEY', None)
|
||||||
|
if not OPENAI_KEY:
|
||||||
|
print("OPENAI_KEY not set")
|
||||||
|
return
|
||||||
|
OPENAI_ORG = os.environ.get('OPENAI_ORG', None)
|
||||||
|
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN', None)
|
||||||
|
if not GITHUB_TOKEN:
|
||||||
|
print("GITHUB_TOKEN not set")
|
||||||
|
return
|
||||||
### DEBUG
|
### DEBUG
|
||||||
print(event_payload)
|
print(event_payload)
|
||||||
print(GITHUB_REPOSITORY)
|
|
||||||
print(GITHUB_EVENT_NAME)
|
|
||||||
print(GITHUB_EVENT_PATH)
|
|
||||||
print(RUNNER_DEBUG)
|
|
||||||
|
|
||||||
|
settings.set("OPENAI.KEY", OPENAI_KEY)
|
||||||
|
if OPENAI_ORG:
|
||||||
|
settings.set("OPENAI.ORG", OPENAI_ORG)
|
||||||
|
settings.set("GITHUB.USER_TOKEN", GITHUB_TOKEN)
|
||||||
|
settings.set("GITHUB.DEPLOYMENT_TYPE", "user")
|
||||||
if GITHUB_EVENT_NAME == "pull_request":
|
if GITHUB_EVENT_NAME == "pull_request":
|
||||||
print("PR event")
|
action = event_payload.get("action", None)
|
||||||
|
if action in ["opened", "reopened"]:
|
||||||
|
pr_url = event_payload.get("pull_request", {}).get("url", None)
|
||||||
|
if pr_url:
|
||||||
|
PRReviewer(pr_url).review()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user