-
Notifications
You must be signed in to change notification settings - Fork 3
40 lines (38 loc) · 1.37 KB
/
slack-notification.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
40
name: Slack Notification
on:
pull_request:
types: [opened]
jobs:
slack-notify:
name: Slack Notification
runs-on: ubuntu-latest
env:
PULL_REQUEST_BODY: ${{ github.event.pull_request.body || 'The person did not write a PR description 😢' }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- name: Convert PR body to Slack format
id: slackify
uses: LoveToKnow/[email protected]
with:
text: ${{ env.PULL_REQUEST_BODY }}
- name: Generate notification payload
id: notification
env:
TITLE: ${{ github.event.pull_request.title }}
USER_LOGIN: ${{ github.event.pull_request.user.login }}
HTML_URL: ${{ github.event.pull_request.html_url }}
run: |
payload=$(node ./.github/utils/slack-notify.mjs '${{ env.TITLE }}' '${{ env.USER_LOGIN }}' '${{ env.HTML_URL }}' '${{ steps.slackify.outputs.text }}')
echo "payload=${payload//$'\n'/'%0A'}" >> $GITHUB_OUTPUT
- name: Send PR to Slack
id: slack
uses: slackapi/[email protected]
with:
payload: ${{ steps.notification.outputs.payload }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK