Skip to content

Commit 5742a9b

Browse files
committed
Github custom action development
1 parent d1b6b3b commit 5742a9b

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

.github/workflows/review.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
on: [push]
2+
3+
jobs:
4+
pr_agent_job:
5+
runs-on: ubuntu-latest
6+
name: Run pr agent on every pull request
7+
steps:
8+
- name: PR Agent action step
9+
id: pragent
10+
uses: Codium-ai/pr-agent@feature/github_action
11+
with:
12+
openai-key: "TBD: openai key"
13+

Dockerfile.github_action

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.10 as base
2+
3+
WORKDIR /app
4+
ADD requirements.txt .
5+
RUN pip install -r requirements.txt && rm requirements.txt
6+
ENV PYTHONPATH=/app
7+
ADD pr_agent pr_agent
8+
ADD github_action/entrypoint.sh /
9+
RUN chmod +x /entrypoint.sh
10+
ENTRYPOINT ["/entrypoint.sh"]

action.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: 'PR Agent'
2+
description: 'Summarize, review and suggest improvements for pull requests'
3+
inputs:
4+
openai-key: # id of input
5+
description: 'OpenAI Key'
6+
required: true
7+
default: ''
8+
runs:
9+
using: 'docker'
10+
image: 'Dockerfile.github_action'

github_action/entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
python /app/pr_agent/servers/github_action_runner.py
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import json
2+
import os
3+
4+
5+
def run_action():
6+
GITHUB_EVENT_NAME = os.environ.get('GITHUB_EVENT_NAME', None)
7+
if not GITHUB_EVENT_NAME:
8+
print("GITHUB_EVENT_NAME not set")
9+
return
10+
GITHUB_EVENT_PATH = os.environ.get('GITHUB_EVENT_PATH', None)
11+
if not GITHUB_EVENT_PATH:
12+
print("GITHUB_EVENT_PATH not set")
13+
return
14+
event_payload = json.load(open(GITHUB_EVENT_PATH, 'r'))
15+
GITHUB_REPOSITORY = os.environ.get('GITHUB_REPOSITORY', None)
16+
if not GITHUB_REPOSITORY:
17+
print("GITHUB_REPOSITORY not set")
18+
return
19+
print(event_payload)
20+
print(GITHUB_REPOSITORY)
21+
print(GITHUB_EVENT_NAME)
22+
print(GITHUB_EVENT_PATH)
23+
print("Hello from run_action")
24+
RUNNER_DEBUG = os.environ.get('RUNNER_DEBUG', None)
25+
if not RUNNER_DEBUG:
26+
print("RUNNER_DEBUG not set")
27+
return
28+
print(RUNNER_DEBUG)

0 commit comments

Comments
 (0)