From 4559cd721ea104598a9369469eaf4162a430d774 Mon Sep 17 00:00:00 2001 From: utsman Date: Sat, 25 Jan 2025 20:44:05 +0700 Subject: [PATCH] Feat: Add PR status check before code review, enhance workflow, include issue read for PR check, introduce logic to determine existence of PR via branch name, set PR number as output for action. --- .github/workflows/code-review.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/code-review.yml b/.github/workflows/code-review.yml index 5039b93..17e1b39 100644 --- a/.github/workflows/code-review.yml +++ b/.github/workflows/code-review.yml @@ -10,17 +10,34 @@ jobs: permissions: contents: read pull-requests: write + issues: read # Diperlukan untuk cek PR steps: - name: Checkout code uses: actions/checkout@v4 + - name: Get PR status + id: check-pr + env: + BRANCH_NAME: ${{ github.ref_name }} + run: | + # Cek apakah ada PR yang terkait dengan branch + pr=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number') + if [ -z "$pr" ]; then + echo "::set-output name=has_pr::false" + else + echo "::set-output name=has_pr::true" + echo "::set-output name=pr_number::$pr" + fi + - name: Run Customized Review + if: steps.check-pr.outputs.has_pr == 'true' uses: .github/actions/code-reviewer with: gemini-api-key: ${{ secrets.GEMINI_API_KEY }} github-token: ${{ secrets.GITHUB_TOKEN }} model-name: 'gemini-1.5-pro-latest' + pr-number: ${{ steps.check-pr.outputs.pr_number }} custom-instructions: | **Language-Specific Checks:** - PEP8 compliance