From 0711f0c5db9d4a9d97c1693fc61713f5016f5128 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Wed, 2 Apr 2025 11:48:51 +0200 Subject: [PATCH 1/3] feat: add PR slack notification workflow --- .github/workflows/slack-notify.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/slack-notify.yml diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml new file mode 100644 index 000000000..f5ef2df6c --- /dev/null +++ b/.github/workflows/slack-notify.yml @@ -0,0 +1,19 @@ +name: Notify Reviewers on Slack + +on: + pull_request: + types: [review_requested] + +jobs: + notify: + runs-on: ubuntu-latest + steps: + - name: Send Slack Notification + uses: slackapi/slack-github-action@v1.24.0 + with: + payload: | + { + "text": "👀 New PR needs review: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> requested by ${{ github.event.pull_request.user.login }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} From 2c4a2c08db8b4bccaf8e9713eb98dfdb78efdd2d Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Wed, 2 Apr 2025 11:53:41 +0200 Subject: [PATCH 2/3] feat: add names to slack message --- .github/workflows/slack-notify.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index f5ef2df6c..b1516c958 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -6,14 +6,19 @@ on: jobs: notify: + if: github.event.action == 'review_requested' && github.event.requested_reviewer != null runs-on: ubuntu-latest steps: + - name: Extract Reviewer Info + id: extract + run: echo "reviewer=${{ github.event.requested_reviewer.login }}" >> $GITHUB_OUTPUT + - name: Send Slack Notification uses: slackapi/slack-github-action@v1.24.0 with: payload: | { - "text": "👀 New PR needs review: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}> requested by ${{ github.event.pull_request.user.login }}" + "text": "👀 <${{ github.event.pull_request.user.login }}> has requested a review from *${{ steps.extract.outputs.reviewer }}* on PR: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>." } env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file From bede30437751083e83392afba3b4ae2baea96664 Mon Sep 17 00:00:00 2001 From: Gabriele Picco Date: Wed, 2 Apr 2025 11:54:57 +0200 Subject: [PATCH 3/3] feat: group reviewers --- .github/workflows/slack-notify.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index b1516c958..c32e59860 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -6,19 +6,21 @@ on: jobs: notify: - if: github.event.action == 'review_requested' && github.event.requested_reviewer != null + if: github.event.action == 'review_requested' runs-on: ubuntu-latest steps: - - name: Extract Reviewer Info - id: extract - run: echo "reviewer=${{ github.event.requested_reviewer.login }}" >> $GITHUB_OUTPUT + - name: Format reviewer list + id: reviewers + run: | + reviewers=$(echo "${{ toJson(github.event.pull_request.requested_reviewers) }}" | jq -r '.[].login' | paste -sd ", " -) + echo "reviewers=$reviewers" >> $GITHUB_OUTPUT - name: Send Slack Notification uses: slackapi/slack-github-action@v1.24.0 with: payload: | { - "text": "👀 <${{ github.event.pull_request.user.login }}> has requested a review from *${{ steps.extract.outputs.reviewer }}* on PR: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>." + "text": "👀 <${{ github.event.pull_request.user.login }}> has requested reviews from *${{ steps.reviewers.outputs.reviewers }}* on PR: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>." } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file