-
Notifications
You must be signed in to change notification settings - Fork 6
91 lines (79 loc) · 2.9 KB
/
Copy pathnotifications.yml
File metadata and controls
91 lines (79 loc) · 2.9 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Notifications
on:
issues:
types: [opened, edited, deleted, closed]
issue_comment:
types: [created]
workflow_run:
workflows: ["Release"]
types: [completed]
pull_request_target:
types: [opened, closed, edited, review_requested]
jobs:
issue-notification:
if: github.event_name == 'issues' || github.event_name == 'issue_comment'
runs-on: ubuntu-latest
steps:
- name: Notify on Issue or Comment
if: github.actor != 'Tanq16'
run: |
if [ "${{ github.event_name }}" = "issues" ]; then
ACTION="${{ github.event.action }}"
TITLE="${{ github.event.issue.title }}"
URL="${{ github.event.issue.html_url }}"
MESSAGE="Issue ${ACTION}: **${TITLE}**\n${URL}"
else
URL="${{ github.event.issue.html_url }}"
MESSAGE="New comment on issue\n${URL}"
fi
curl -H "Content-Type: application/json" -X POST \
-d "{\"content\": \"*${{ github.repository }}*\n${MESSAGE}\nBy: **${{ github.actor }}**\"}" \
${{ secrets.DISCORD_WEBHOOK }}
build-notification:
if: github.event_name == 'workflow_run'
runs-on: ubuntu-latest
steps:
- name: Notify on Build Status
run: |
WORKFLOW="${{ github.event.workflow_run.name }}"
CONCLUSION="${{ github.event.workflow_run.conclusion }}"
URL="${{ github.event.workflow_run.html_url }}"
if [ "$CONCLUSION" = "success" ]; then
EMOJI="✅"
else
EMOJI="❌"
fi
curl -H "Content-Type: application/json" -X POST \
-d "{\"content\": \"${EMOJI} *${{ github.repository }}*\n**${WORKFLOW}** - ${CONCLUSION}\n${URL}\"}" \
${{ secrets.DISCORD_WEBHOOK }}
pr-notification:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
steps:
- name: Notify on PR Activity
if: github.actor != 'Tanq16'
run: |
ACTION="${{ github.event.action }}"
TITLE="${{ github.event.pull_request.title }}"
URL="${{ github.event.pull_request.html_url }}"
case "$ACTION" in
opened)
MESSAGE="🆕 New PR: **${TITLE}**"
;;
closed)
if [ "${{ github.event.pull_request.merged }}" = "true" ]; then
MESSAGE="🎉 PR merged: **${TITLE}**"
else
MESSAGE="🚫 PR closed: **${TITLE}**"
fi
;;
review_requested)
MESSAGE="👀 Review requested: **${TITLE}**"
;;
*)
MESSAGE="PR ${ACTION}: **${TITLE}**"
;;
esac
curl -H "Content-Type: application/json" -X POST \
-d "{\"content\": \"*${{ github.repository }}*\n${MESSAGE}\n${URL}\nBy: **${{ github.actor }}**\"}" \
${{ secrets.DISCORD_WEBHOOK }}