-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Try trigger chatgpt review on draft pr * Change chatgpt github action try file mode add workflow dispatch try another action try action try another action updated action version updated github annotations fixed typo try another add label change label condition try on comment run always for now add checks fixes add more checks merge steps dummy commit to test after editing title added gpt recommendations undo gpt recommendations changed to use commit message * [autoreview] trigger chatgpt * [autoreview] add echo * [autoreview] fix condition
- Loading branch information
Showing
1 changed file
with
41 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,51 @@ | ||
name: ChatGPT | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
workflow_dispatch: | ||
|
||
jobs: | ||
review: | ||
if: ${{ !github.event.pull_request.draft }} | ||
runs-on: ubuntu-latest | ||
name: review | ||
steps: | ||
- uses: anc95/[email protected] | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check Conditions | ||
id: check | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
OPENAI_API_ENDPOINT: https://api.openai.com/v1 | ||
MODEL: gpt-4 | ||
PROMPT: "Please highlight only the most important logical errors, or areas for improvement of the Pull Request. If the Pull Request adheres to all guidelines and best practices, simply respond with 'No suggestions, the PR is good.'" | ||
top_p: 1 # Determines the portion of the probability mass to sample from - https://platform.openai.com/docs/api-reference/chat/create#chat/create-top_p | ||
temperature: 0.2 # Controls randomness of the output - https://platform.openai.com/docs/api-reference/chat/create#chat/create-temperature | ||
max_tokens: 2000 | ||
MAX_PATCH_LENGTH: 5000 # Ignored and won't review if the patch/diff length is larger than this value | ||
run: | | ||
# Fetch the latest commit message associated with this PR | ||
LATEST_COMMIT_MESSAGE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits | \ | ||
jq -r '.[-1].commit.message') | ||
echo "Latest Commit Message: $LATEST_COMMIT_MESSAGE" | ||
# Fetch the PR creator | ||
PRCREATOR=$(curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }} | jq -r .user.login) | ||
# Check if the PR creator is in the group | ||
IS_IN_GROUP=$(curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/orgs/freeverseio/teams/ziggy/members/$PRCREATOR) | ||
if [ "$IS_IN_GROUP" != "null" ]; then | ||
echo "Commenter is in the group." | ||
echo "is_in_group=true" >> $GITHUB_ENV | ||
else | ||
echo "Commenter is not in the group." | ||
echo "is_in_group=false" >> $GITHUB_ENV | ||
fi | ||
# Check if the latest commit message contains [autoreview] | ||
echo "is_autoreview=$(if [[ "$LATEST_COMMIT_MESSAGE" == *"[autoreview]"* ]]; then echo 'true'; else echo 'false'; fi)" >> $GITHUB_ENV | ||
echo "is_draft=${{ github.event.pull_request.draft }}" >> $GITHUB_ENV | ||
- name: Run if Draft, Correct User, and AutoReview | ||
if: env.is_draft == 'true' && env.is_in_group == 'true' && env.is_autoreview == 'true' | ||
uses: gvasilei/[email protected] | ||
env: | ||
NODE_OPTIONS: '--experimental-fetch' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
openai_api_key: ${{ secrets.OPENAI_API_KEY }} | ||
model_name: gpt-4 |