From bf507aab0578bd347772a4e6461901aac1e0ba15 Mon Sep 17 00:00:00 2001 From: phoenixdong Date: Thu, 6 Jun 2024 09:30:32 +0800 Subject: [PATCH] add review check --- .github/workflows/review.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/review.yml diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml new file mode 100644 index 000000000..7539a3c16 --- /dev/null +++ b/.github/workflows/review.yml @@ -0,0 +1,35 @@ +name: flagscale-review + +on: + pull_request: + branches: [ "main" ] + types: [opened, synchronize, reopened] + +jobs: + check-approver: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Get PR Approvals + id: get_approvals + run: | + PR_NUMBER=$(jq --raw-output .number "$GITHUB_EVENT_PATH") + APPROVERS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/reviews" \ + | jq -r '.[] | select(.state == "APPROVED") | .user.login') + + echo "APPROVERS=$APPROVERS" >> $GITHUB_ENV + + - name: Check for Specific Approver + id: check_approver + run: | + SPECIFIC_APPROVER="aoyulong" + if echo "$APPROVERS" | grep -q "$SPECIFIC_APPROVER"; then + echo "Specific approver has approved the PR." + else + echo "The PR has not been approved by the specific approver." + exit 1 + fi