refactor: Tweak thresholds #47
This file contains hidden or 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: LGTM Review | |
| on: | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| lgtm-review: | |
| if: | | |
| github.event.issue.pull_request && | |
| startsWith(github.event.comment.body, '/lgtm review') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check if commenter has write access | |
| id: check-permission | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| USER=${{ github.event.comment.user.login }} | |
| REPO=${{ github.repository }} | |
| PERMISSION=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \ | |
| https://api.github.com/repos/$REPO/collaborators/$USER/permission \ | |
| | jq -r '.permission') | |
| if [[ "$PERMISSION" == "admin" || "$PERMISSION" == "maintain" || "$PERMISSION" == "write" ]]; then | |
| echo "HAS_PERMISSION=true" >> $GITHUB_ENV | |
| else | |
| echo "HAS_PERMISSION=false" >> $GITHUB_ENV | |
| fi | |
| - name: Fail if unauthorized | |
| if: env.HAS_PERMISSION == 'false' | |
| run: | | |
| echo "User ${{ github.event.comment.user.login }} is not authorized to trigger this workflow." | |
| exit 1 | |
| - name: Checkout PR code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| ref: refs/pull/${{ github.event.issue.number }}/merge | |
| - name: Run LGTM Review | |
| run: | | |
| docker run --rm \ | |
| -v "${{ github.workspace }}:/workspace" \ | |
| -w /workspace \ | |
| elementsinteractive/lgtm-ai \ | |
| review \ | |
| --git-api-key "${{ secrets.GITHUB_TOKEN }}" \ | |
| --ai-api-key "${{ secrets.AI_API_TOKEN }}" \ | |
| -vv \ | |
| "https://github.com/${{ github.repository }}/pull/${{ github.event.issue.number }}" |