File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments