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