File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Notify Slack on New Issue or PR
2
+
3
+ on :
4
+ issues :
5
+ types : [opened]
6
+ pull_request :
7
+ types : [opened]
8
+
9
+ jobs :
10
+ notify :
11
+ runs-on : ubuntu-latest
12
+ steps :
13
+ - name : Send Slack notification
14
+ run : |
15
+ if [[ "${{ github.event_name }}" == "issues" ]]; then
16
+ TYPE="Issue"
17
+ TITLE="${{ github.event.issue.title }}"
18
+ URL="${{ github.event.issue.html_url }}"
19
+ USER="${{ github.event.issue.user.login }}"
20
+ else
21
+ TYPE="Pull Request"
22
+ TITLE="${{ github.event.pull_request.title }}"
23
+ URL="${{ github.event.pull_request.html_url }}"
24
+ USER="${{ github.event.pull_request.user.login }}"
25
+ fi
26
+
27
+ PAYLOAD=$(jq -n \
28
+ --arg type "$TYPE" \
29
+ --arg title "$TITLE" \
30
+ --arg url "$URL" \
31
+ --arg user "$USER" \
32
+ '{
33
+ text: "*New GitHub \($type)* :sparkles:",
34
+ attachments: [
35
+ {
36
+ color: "#36a64f",
37
+ title: $title,
38
+ title_link: $url,
39
+ fields: [
40
+ {
41
+ title: "Author",
42
+ value: $user,
43
+ short: true
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }')
49
+
50
+ curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL
51
+ env :
52
+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
You can’t perform that action at this time.
0 commit comments