File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Notify Slack On New Issue
2+
3+ on :
4+ issues :
5+ types : [opened]
6+
7+ jobs :
8+ notify-slack :
9+ name : Send issue notification to Slack
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Post new issue to Slack
13+ env :
14+ SLACK_WEBHOOK_URL : ${{ secrets.GATOR_BOT_SLACK_WEBHOOK_URL }}
15+ ISSUE_TITLE : ${{ github.event.issue.title }}
16+ ISSUE_URL : ${{ github.event.issue.html_url }}
17+ ISSUE_AUTHOR : ${{ github.event.issue.user.login }}
18+ run : |
19+ if [ -z "$SLACK_WEBHOOK_URL" ]; then
20+ echo "GATOR_BOT_SLACK_WEBHOOK_URL is not set."
21+ exit 1
22+ fi
23+
24+ payload=$(jq -n \
25+ --arg title "$ISSUE_TITLE" \
26+ --arg url "$ISSUE_URL" \
27+ --arg author "$ISSUE_AUTHOR" \
28+ '{
29+ "text": "New GitHub issue created",
30+ "blocks": [
31+ {
32+ "type": "section",
33+ "text": {
34+ "type": "mrkdwn",
35+ "text": "*New GitHub issue created*"
36+ }
37+ },
38+ {
39+ "type": "section",
40+ "fields": [
41+ {
42+ "type": "mrkdwn",
43+ "text": "*Title:*\n\($title)"
44+ },
45+ {
46+ "type": "mrkdwn",
47+ "text": "*Raised by:*\n\($author)"
48+ },
49+ {
50+ "type": "mrkdwn",
51+ "text": "*Link:*\n<\($url)|View issue>"
52+ }
53+ ]
54+ }
55+ ]
56+ }')
57+
58+ curl -sS -X POST -H 'Content-type: application/json' \
59+ --data "$payload" \
60+ "$SLACK_WEBHOOK_URL"
You can’t perform that action at this time.
0 commit comments