polkadot v1.2.0 #86
Workflow file for this run
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
name: ChatGPT | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
workflow_dispatch: | |
jobs: | |
review: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Check Conditions | |
id: check | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
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 |