@@ -3,48 +3,6 @@ name: Discord Notifications
33on :
44 push :
55 branches : [master]
6- pull_request :
7- branches : [master]
8- types : [opened, reopened, synchronize, closed, ready_for_review, converted_to_draft, edited, labeled, unlabeled, assigned, unassigned, review_requested, review_request_removed]
9- pull_request_review :
10- types : [submitted, edited, dismissed]
11- pull_request_review_comment :
12- types : [created, edited, deleted]
13- issues :
14- types : [opened, reopened, closed, edited, labeled, unlabeled, assigned, unassigned, milestoned, demilestoned, transferred, pinned, unpinned, locked, unlocked, deleted]
15- issue_comment :
16- types : [created, edited, deleted]
17- release :
18- types : [published, unpublished, created, edited, deleted, prereleased, released]
19- create :
20- delete :
21- fork :
22- watch :
23- types : [started]
24- discussion :
25- types : [created, edited, deleted, pinned, unpinned, locked, unlocked, transferred, category_changed, answered, unanswered]
26- discussion_comment :
27- types : [created, edited, deleted]
28- workflow_dispatch :
29- repository_dispatch :
30- public :
31- member :
32- types : [added, edited, removed]
33- milestone :
34- types : [created, closed, opened, edited, deleted]
35- label :
36- types : [created, edited, deleted]
37- project :
38- types : [created, closed, reopened, edited, deleted]
39- project_card :
40- types : [created, moved, converted, edited, deleted]
41- project_column :
42- types : [created, updated, moved, deleted]
43- status :
44- deployment :
45- deployment_status :
46- page_build :
47- gollum :
486
497jobs :
508 notify :
@@ -83,145 +41,6 @@ jobs:
8341
8442 if [ "$EVENT_NAME" = "push" ]; then
8543 MESSAGE="$(jq -r '.head_commit.message // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 600)"
86- elif [ "$EVENT_NAME" = "pull_request" ]; then
87- PR_TITLE="$(jq -r '.pull_request.title // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 400)"
88- PR_NUM="$(jq -r '.pull_request.number // ""' "$EVENT_JSON")"
89- PR_STATE="$(jq -r '.pull_request.state // ""' "$EVENT_JSON")"
90- MESSAGE="PR #${PR_NUM}: ${PR_TITLE}"
91- if [ -n "$PR_STATE" ]; then
92- EXTRA_NAME="State"
93- EXTRA_VALUE="$PR_STATE"
94- fi
95- elif [ "$EVENT_NAME" = "pull_request_review" ]; then
96- PR_NUM="$(jq -r '.pull_request.number // ""' "$EVENT_JSON")"
97- STATE="$(jq -r '.review.state // ""' "$EVENT_JSON")"
98- MESSAGE="Review on PR #${PR_NUM}: ${STATE}"
99- elif [ "$EVENT_NAME" = "pull_request_review_comment" ]; then
100- PR_NUM="$(jq -r '.pull_request.number // ""' "$EVENT_JSON")"
101- MESSAGE="Review comment on PR #${PR_NUM}"
102- PTH="$(jq -r '.comment.path // ""' "$EVENT_JSON")"
103- if [ -n "$PTH" ]; then
104- EXTRA_NAME="File"
105- EXTRA_VALUE="$PTH"
106- fi
107- elif [ "$EVENT_NAME" = "issues" ]; then
108- I_TITLE="$(jq -r '.issue.title // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 400)"
109- I_NUM="$(jq -r '.issue.number // ""' "$EVENT_JSON")"
110- I_STATE="$(jq -r '.issue.state // ""' "$EVENT_JSON")"
111- MESSAGE="Issue #${I_NUM}: ${I_TITLE}"
112- if [ -n "$I_STATE" ]; then
113- EXTRA_NAME="State"
114- EXTRA_VALUE="$I_STATE"
115- fi
116- elif [ "$EVENT_NAME" = "issue_comment" ]; then
117- I_NUM="$(jq -r '.issue.number // ""' "$EVENT_JSON")"
118- BODY="$(jq -r '.comment.body // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 250)"
119- MESSAGE="$(printf "Comment on Issue #%s\n\n%s" "$I_NUM" "$BODY")"
120- elif [ "$EVENT_NAME" = "release" ]; then
121- R_NAME="$(jq -r '.release.name // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 400)"
122- R_TAG="$(jq -r '.release.tag_name // ""' "$EVENT_JSON")"
123- MESSAGE="Release: ${R_NAME}"
124- if [ -n "$R_TAG" ]; then
125- EXTRA_NAME="Tag"
126- EXTRA_VALUE="$R_TAG"
127- fi
128- elif [ "$EVENT_NAME" = "discussion" ]; then
129- D_TITLE="$(jq -r '.discussion.title // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 400)"
130- MESSAGE="Discussion: ${D_TITLE}"
131- CAT="$(jq -r '.discussion.category.name // ""' "$EVENT_JSON")"
132- if [ -n "$CAT" ]; then
133- EXTRA_NAME="Category"
134- EXTRA_VALUE="$CAT"
135- fi
136- elif [ "$EVENT_NAME" = "discussion_comment" ]; then
137- BODY="$(jq -r '.comment.body // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 250)"
138- MESSAGE="$(printf "Discussion comment\n\n%s" "$BODY")"
139- elif [ "$EVENT_NAME" = "create" ]; then
140- RT="$(jq -r '.ref_type // ""' "$EVENT_JSON")"
141- R="$(jq -r '.ref // ""' "$EVENT_JSON")"
142- MESSAGE="Created ${RT}: ${R}"
143- elif [ "$EVENT_NAME" = "delete" ]; then
144- RT="$(jq -r '.ref_type // ""' "$EVENT_JSON")"
145- R="$(jq -r '.ref // ""' "$EVENT_JSON")"
146- MESSAGE="Deleted ${RT}: ${R}"
147- elif [ "$EVENT_NAME" = "fork" ]; then
148- F_FULL="$(jq -r '.forkee.full_name // ""' "$EVENT_JSON")"
149- MESSAGE="Repository was forked."
150- if [ -n "$F_FULL" ]; then
151- EXTRA_NAME="Fork"
152- EXTRA_VALUE="$F_FULL"
153- fi
154- elif [ "$EVENT_NAME" = "watch" ]; then
155- MESSAGE="Repository was starred."
156- elif [ "$EVENT_NAME" = "public" ]; then
157- MESSAGE="Repository is now public."
158- elif [ "$EVENT_NAME" = "member" ]; then
159- M="$(jq -r '.member.login // ""' "$EVENT_JSON")"
160- MESSAGE="A collaborator change occurred."
161- if [ -n "$M" ]; then
162- EXTRA_NAME="Member"
163- EXTRA_VALUE="$M"
164- fi
165- elif [ "$EVENT_NAME" = "milestone" ]; then
166- MT="$(jq -r '.milestone.title // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 200)"
167- MS="$(jq -r '.milestone.state // ""' "$EVENT_JSON")"
168- MESSAGE="Milestone: ${MT}"
169- if [ -n "$MS" ]; then
170- EXTRA_NAME="State"
171- EXTRA_VALUE="$MS"
172- fi
173- elif [ "$EVENT_NAME" = "label" ]; then
174- LN="$(jq -r '.label.name // ""' "$EVENT_JSON")"
175- MESSAGE="Label updated: ${LN}"
176- elif [ "$EVENT_NAME" = "project" ]; then
177- PN="$(jq -r '.project.name // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 200)"
178- MESSAGE="Project: ${PN}"
179- elif [ "$EVENT_NAME" = "project_column" ]; then
180- CN="$(jq -r '.project_column.name // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 200)"
181- MESSAGE="Project column updated: ${CN}"
182- elif [ "$EVENT_NAME" = "project_card" ]; then
183- MESSAGE="Project card updated."
184- elif [ "$EVENT_NAME" = "status" ]; then
185- STATE="$(jq -r '.state // ""' "$EVENT_JSON")"
186- DESC="$(jq -r '.description // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 200)"
187- MESSAGE="Commit status: ${STATE}"
188- if [ -n "$DESC" ]; then
189- MESSAGE="$(printf "%s\n\n%s" "$MESSAGE" "$DESC")"
190- fi
191- elif [ "$EVENT_NAME" = "deployment" ]; then
192- ENVN="$(jq -r '.deployment.environment // ""' "$EVENT_JSON")"
193- MESSAGE="Deployment created."
194- if [ -n "$ENVN" ]; then
195- EXTRA_NAME="Env"
196- EXTRA_VALUE="$ENVN"
197- fi
198- elif [ "$EVENT_NAME" = "deployment_status" ]; then
199- ENVN="$(jq -r '.deployment.environment // ""' "$EVENT_JSON")"
200- STATE="$(jq -r '.deployment_status.state // ""' "$EVENT_JSON")"
201- MESSAGE="Deployment status: ${STATE}"
202- if [ -n "$ENVN" ] || [ -n "$STATE" ]; then
203- EXTRA_NAME="Env"
204- EXTRA_VALUE="${ENVN}${ENVN:+ · }${STATE}"
205- fi
206- elif [ "$EVENT_NAME" = "page_build" ]; then
207- MESSAGE="GitHub Pages build completed."
208- elif [ "$EVENT_NAME" = "gollum" ]; then
209- P_TITLE="$(jq -r '.pages[0].title // "" | gsub("\\\\n"; "\n")' "$EVENT_JSON" | head -c 200)"
210- P_ACTION="$(jq -r '.pages[0].action // ""' "$EVENT_JSON")"
211- MESSAGE="Wiki update: ${P_TITLE}"
212- if [ -n "$P_ACTION" ]; then
213- EXTRA_NAME="Action"
214- EXTRA_VALUE="$P_ACTION"
215- fi
216- elif [ "$EVENT_NAME" = "repository_dispatch" ]; then
217- ET="$(jq -r '.action // .client_payload.event_type // ""' "$EVENT_JSON")"
218- MESSAGE="Repository dispatch received."
219- if [ -n "$ET" ]; then
220- EXTRA_NAME="Type"
221- EXTRA_VALUE="$ET"
222- fi
223- elif [ "$EVENT_NAME" = "workflow_dispatch" ]; then
224- MESSAGE="Workflow was manually triggered."
22544 fi
22645
22746 BASE_LINE="$(printf '%s' "$BASE_LINE" | tr -d '\r')"
0 commit comments