Skip to content

Commit 40145c2

Browse files
authored
add slack notification with button workflow (#590)
1 parent b4cd641 commit 40145c2

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Notify Slack on Issue Creation
2+
3+
permissions:
4+
issues: read
5+
6+
on:
7+
issues:
8+
types: [opened]
9+
10+
jobs:
11+
send-notification:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: "3.8"
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install requests
24+
25+
- name: Send notification to Slack
26+
env:
27+
SLACK_NOTIFY_TO_PDI_JIRA_WEBHOOK: ${{ secrets.SLACK_NOTIFY_TO_PDI_JIRA_WEBHOOK }}
28+
ISSUE_TITLE: ${{ github.event.issue.title }}
29+
ISSUE_BODY: ${{ github.event.issue.body }}
30+
REPOSITORY_NAME: ${{ github.repository }}
31+
GITHUB_EVENT_ISSUE_HTML_URL: ${{ github.event.issue.html_url }}
32+
run: |
33+
python <<EOF
34+
import os
35+
import requests
36+
import json
37+
headers = {'Content-Type': 'application/json'}
38+
message = {
39+
"text": f"New issue created in {os.environ['REPOSITORY_NAME']}: *{os.environ['ISSUE_TITLE']}*\n{os.environ['GITHUB_EVENT_ISSUE_HTML_URL']}",
40+
"REPOSITORY_NAME": os.environ['REPOSITORY_NAME'],
41+
"GITHUB_ISSUE": os.environ['GITHUB_EVENT_ISSUE_HTML_URL'],
42+
"ISSUE_TITLE": os.environ['ISSUE_TITLE']
43+
}
44+
response = requests.post(os.environ['SLACK_NOTIFY_TO_PDI_JIRA_WEBHOOK'], headers=headers, data=json.dumps(message))
45+
EOF

0 commit comments

Comments
 (0)