Skip to content

Commit

Permalink
Fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mandeepnh5 committed Dec 28, 2024
1 parent dbe1183 commit ac05f7e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -471,22 +471,24 @@ jobs:
- name: Check CodeRabbit.ai Approval
run: |
reviews=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews) || {
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews)
if [ $? -ne 0 ]; then
echo "Error: Failed to fetch PR reviews"
exit 1
}
fi
if ! echo "$reviews" | jq . >/dev/null 2>&1; then
echo "Error: Invalid JSON response from GitHub API"
exit 1
}
fi
approval_count=$(echo "$reviews" | jq '[.[] | select(.state == "APPROVED" and .user.login == "coderabbitai")] | length')
if [[ ! "$approval_count" =~ ^[0-9]+$ ]]; then
echo "Error: Failed to parse approval count"
exit 1
}
fi
if [[ $approval_count -eq 0 ]]; then
echo "Error: PR is not approved by CodeRabbit.ai"
Expand Down

0 comments on commit ac05f7e

Please sign in to comment.