-
Notifications
You must be signed in to change notification settings - Fork 2k
41 lines (38 loc) · 1.24 KB
/
slack-alerts.yml
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
name: Send slack alerts for new GitHub issues
on:
issues: # workflow.yml should be placed in the default branch to trigger for issues
types: [opened]
jobs:
send-slack-alert:
runs-on: ubuntu-latest
steps:
- name: Check issue title and URL
id: check
env:
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_URL: ${{ github.event.issue.html_url }}
run: |
if [[ ! "$ISSUE_TITLE" =~ ^[a-zA-Z0-9\ \-\_\:\'\(\)\`]+$ ]]; then
echo "Invalid characters in issue title"
exit 1
fi
echo "TITLE=$ISSUE_TITLE" >> $GITHUB_ENV
echo "URL=$ISSUE_URL" >> $GITHUB_ENV
- name: Post to a Slack channel
id: slack
uses: slackapi/[email protected]
with:
channel-id: "h2o-3-github-issues"
payload: |
{
"text": ":github: *H2O-3 GitHub Issue Opened*",
"attachments": [
{
"text": "*Title:* ${{ env.TITLE }}\n*Link:* ${{ env.URL }}",
"color": "good",
"fallback": "Build Alert"
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}