-
Notifications
You must be signed in to change notification settings - Fork 322
39 lines (37 loc) · 1.49 KB
/
ci-notify-slack.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: PR Slack Notification
on:
pull_request:
types: [review_requested]
jobs:
notify-slack:
name: Notify Slack
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get requested team reviewers
id: get-reviewers
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
return "requested_team" in context.payload ? context.payload.requested_team.name : ""
- name: Lookup Slack channel
id: lookup
if: steps.get-reviewers.outputs.result != '""'
run: |
TEAM=${{ steps.get-reviewers.outputs.result }}
CHANNEL=$(jq -r --arg team "$TEAM" '.[$team]' .github/workflows/team-channels.json)
echo "channel=${CHANNEL}" >> $GITHUB_OUTPUT
echo "message=${MESSAGE}" >> $GITHUB_OUTPUT
env:
MESSAGE: ":github: <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>"
- name: Post to a Slack channel
if: steps.get-reviewers.outputs.result != '""' && steps.lookup.outputs.channel != 'null'
id: slack
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
with:
channel-id: ${{ steps.lookup.outputs.channel }}
slack-message: "${{ steps.lookup.outputs.message }}"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }}