Skip to content

Commit

Permalink
refactor: move to docker approach (#3)
Browse files Browse the repository at this point in the history
The current github action is not work on outside in other github actions.
This changes propose to move to docker approach and hope it will fix the problem mentioned above.
  • Loading branch information
xmnlab authored May 30, 2023
1 parent 908dc60 commit a055417
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 25 deletions.
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Container image that runs your code
FROM python:3.8-slim

# Instalando as dependencias
COPY requirements.txt .
RUN pip install -r requirements.txt

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh
COPY main.py /main.py

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
# GitHub Actions ChatGPT PR Reviewer

Requires Python 3.7.1+
This GitHub actions uses OpenAI ChatGPT in order to review the changes
presented in a PR and will recommend improvements.

### How to use

Include the following into your github actions step

```yaml
- name: GitHub Actions ChatGPT PR Reviewer
uses: osl-incubator/[email protected]
with:
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
openai_model: 'gpt-3.5-turbo'
openai_temperature: 0.5
openai_max_tokens: 2048
github_token: ${{ secrets.GITHUB_TOKEN }}
github_pr_id: ${{ github.event.number }}
```
Note: this GitHub actions is based on the following tutorial:
https://shipyard.build/blog/your-first-python-github-action/
Expand Down
33 changes: 9 additions & 24 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,12 @@ inputs:
required: true
default: ''
runs:
using: 'composite'
steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Dependencies
shell: bash
run: pip install "openai==0.27.*" "PyGithub~=1.57" "requests~=2.28.2"

- name: Pass Inputs to Shell
shell: bash
run: |
echo "OPENAI_API_KEY=${{ inputs.openai_api_key }}" >> $GITHUB_ENV
echo "OPENAI_MODEL=${{ inputs.openai_model }}" >> $GITHUB_ENV
echo "OPENAI_TEMPERATURE=${{ inputs.openai_temperature }}" >> $GITHUB_ENV
echo "OPENAI_MAX_TOKENS=${{ inputs.openai_max_tokens }}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ inputs.github_token }}" >> $GITHUB_ENV
echo "GITHUB_PR_ID=${{ inputs.github_pr_id }}" >> $GITHUB_ENV
- name: GitHub ChatGPT PR Reviewer
shell: bash
id: run-reviewer
run: python src/gha_gpt_pr_reviewer.py
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.openai_api_key }}
- ${{ inputs.openai_model }}
- ${{ inputs.openai_temperature }}
- ${{ inputs.openai_max_tokens }}
- ${{ inputs.github_token }}
- ${{ inputs.github_pr_id }}
File renamed without changes.
10 changes: 10 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

export OPENAI_API_KEY="$1"
export OPENAI_MODEL="$2"
export OPENAI_TEMPERATURE="$3"
export OPENAI_MAX_TOKENS="$4"
export GITHUB_TOKEN="$5"
export GITHUB_PR_ID="$6"

python /main.py
File renamed without changes.
File renamed without changes.

0 comments on commit a055417

Please sign in to comment.