-
Notifications
You must be signed in to change notification settings - Fork 66
52 lines (48 loc) · 1.48 KB
/
Copy pathslack-on-issue.yml
File metadata and controls
52 lines (48 loc) · 1.48 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
name: Notify Slack on New Issue or PR
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Slack notification
run: |
if [[ "${{ github.event_name }}" == "issues" ]]; then
TYPE="Issue"
TITLE="${{ github.event.issue.title }}"
URL="${{ github.event.issue.html_url }}"
USER="${{ github.event.issue.user.login }}"
else
TYPE="Pull Request"
TITLE="${{ github.event.pull_request.title }}"
URL="${{ github.event.pull_request.html_url }}"
USER="${{ github.event.pull_request.user.login }}"
fi
PAYLOAD=$(jq -n \
--arg type "$TYPE" \
--arg title "$TITLE" \
--arg url "$URL" \
--arg user "$USER" \
'{
text: "*New GitHub \($type)* :sparkles:",
attachments: [
{
color: "#36a64f",
title: $title,
title_link: $url,
fields: [
{
title: "Author",
value: $user,
short: true
}
]
}
]
}')
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}