-
Notifications
You must be signed in to change notification settings - Fork 724
49 lines (43 loc) · 1.51 KB
/
Copy pathbot.yaml
File metadata and controls
49 lines (43 loc) · 1.51 KB
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
42
43
44
45
46
47
48
49
name: Issue notification
on:
issues:
types:
- opened
permissions: {}
jobs:
notify:
if: github.repository == 'pingcap/docs'
runs-on: ubuntu-latest
steps:
- name: Send issue notification
env:
ASSIGNEES: ${{ join(github.event.issue.assignees.*.login, ', ') }}
ISSUE_CREATED_AT: ${{ github.event.issue.created_at }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_REPORTER: ${{ github.event.issue.user.login }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_URL: ${{ github.event.issue.html_url }}
REPOSITORY: ${{ github.repository }}
WEBHOOK_URL: ${{ secrets.BOT_WEBHOOK_URL }}
run: |
issue_date="$(date -u -d "$ISSUE_CREATED_AT" +%F)"
assignees="${ASSIGNEES:-Unassigned}"
message="[$issue_date]: GitHub issue #$ISSUE_NUMBER is created in $REPOSITORY.
Issue title: $ISSUE_TITLE
Issue URL: $ISSUE_URL
Issue reporter: $ISSUE_REPORTER
Assignee: $assignees"
payload="$(jq -n \
--arg text "$message" \
'{"msg_type":"text","content":{"text":$text}}')"
curl --connect-timeout 10 \
--fail-with-body \
--header "Content-Type: application/json" \
--max-time 30 \
--retry 2 \
--retry-connrefused \
--retry-delay 5 \
--show-error \
--silent \
--data-binary "$payload" \
"$WEBHOOK_URL"