From 7f1d20fc4925ad8028975707253e49bd7f4a605c Mon Sep 17 00:00:00 2001 From: kapdroid Date: Wed, 8 Jan 2025 00:07:58 +0530 Subject: [PATCH 1/2] feat(pull-request): pr approved status Signed-off-by: kapdroid --- .github/workflows/pull_request.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/pull_request.yaml diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..d7996c6 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,25 @@ +name: Pull Request + +on: + pull_request_review: + types: [submitted] + +jobs: + check_status: + if: github.event.review.state != 'approved' + runs-on: ubuntu-latest + steps: + - name: Count Approved Reviews + run: | + APPROVED_COUNT=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \ + --jq '[.[] | select(.state == "APPROVED")] | length') + + echo "Number of Approved Reviews: $APPROVED_COUNT" + + if [ "$APPROVED_COUNT" -ge 2 ]; then + echo "PR has $APPROVED_COUNT approved reviews!" + else + echo "PR has only $APPROVED_COUNT approved reviews. Waiting for more approvals." + fi + env: + GH_TOKEN: ${{ secrets.SUPER_SECRET }} \ No newline at end of file From cf79f6e6944f12bbc722bc69e963c872a344e819 Mon Sep 17 00:00:00 2001 From: kapdroid Date: Wed, 8 Jan 2025 00:57:24 +0530 Subject: [PATCH 2/2] test q --- .github/workflows/pull_request.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index d7996c6..74a6ec6 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -1,5 +1,3 @@ -name: Pull Request - on: pull_request_review: types: [submitted] @@ -12,7 +10,7 @@ jobs: - name: Count Approved Reviews run: | APPROVED_COUNT=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \ - --jq '[.[] | select(.state == "APPROVED")] | length') + --jq 'group_by(.user.login) | map(last) | map(select(.state == "APPROVED")) | length') echo "Number of Approved Reviews: $APPROVED_COUNT" @@ -22,4 +20,4 @@ jobs: echo "PR has only $APPROVED_COUNT approved reviews. Waiting for more approvals." fi env: - GH_TOKEN: ${{ secrets.SUPER_SECRET }} \ No newline at end of file + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}