From 8af8a4b2d59450f6e9ccce342cb705b8748194b6 Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Thu, 7 Sep 2023 11:10:17 -0700 Subject: [PATCH] ci(mergify): use mergify to request reviewers (#1657) Signed-off-by: Thuan Vo --- .../workflows/pr-remove-request-review.yml | 25 ------------------- .github/workflows/pr-request-review.yml | 20 ++++----------- .mergify.yml | 19 ++++++++++++++ 3 files changed, 24 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/pr-remove-request-review.yml diff --git a/.github/workflows/pr-remove-request-review.yml b/.github/workflows/pr-remove-request-review.yml deleted file mode 100644 index d9c99077e6..0000000000 --- a/.github/workflows/pr-remove-request-review.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Remove Review Label - -on: - pull_request_review: - types: [submitted, edited, dismissed] - -jobs: - remove-review-label: - runs-on: ubuntu-latest - permissions: - pull-requests: write - - if: github.repository_owner == 'cryostatio' && contains(github.event.pull_request.labels.*.name, 'review-requested') - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Remove label - run: | - pr_number=${{ github.event.pull_request.number }} - echo "Removing 'review-requested' label from the PR" - gh pr edit $pr_number --remove-label "review-requested" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-request-review.yml b/.github/workflows/pr-request-review.yml index 475a02eae8..79e561feb5 100644 --- a/.github/workflows/pr-request-review.yml +++ b/.github/workflows/pr-request-review.yml @@ -8,22 +8,12 @@ on: jobs: request-review: runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} permissions: pull-requests: write if: github.repository_owner == 'cryostatio' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/request_review') - env: - REVIEWERS_TEAM: 'cryostatio/reviewers' steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Add label and request review - run: | - echo "Adding label 'review-requested' to the PR" - gh pr edit ${{ github.event.issue.number }} --add-label "review-requested" - - echo "Requesting review from @$REVIEWERS_TEAM" - gh pr edit ${{ github.event.issue.number }} --add-reviewer $REVIEWERS_TEAM - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + - run: | + # Adding label 'review-requested' to the PR. Mergify will add reviewers. + gh pr edit ${{ github.event.issue.number }} --add-label "review-requested" --repo ${{ github.event.repository.full_name }} diff --git a/.mergify.yml b/.mergify.yml index 33a98dd24d..600de000eb 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -39,3 +39,22 @@ pull_request_rules: is updated. Please revert or drop all changes to the `web-client` submodule from this PR and perform any required frontend work by opening and merging a PR against [cryostat-web](https://github.com/cryostatio/cryostat-web). + + - name: request reviews from the reviewers team + conditions: + - label=review-requested + actions: + request_reviews: + teams: + - "@cryostatio/reviewers" + + - name: remove review-requested label upon reviewing + conditions: + - or: + - "#approved-reviews-by>0" + - "#changes-requested-reviews-by>0" + - "#commented-reviews-by>0" + actions: + label: + remove: + - review-requested