-
Notifications
You must be signed in to change notification settings - Fork 17
87 lines (81 loc) · 2.98 KB
/
pr-notification.yaml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: PR Notification to Google Chat
on:
pull_request:
types: [opened, synchronize, closed]
branches:
- master
- staging/QA
jobs:
notify:
runs-on: ubuntu-latest
if: github.repository == 'AOT-Technologies/forms-flow-ai-charts'
steps:
- name: Determine PR Status
id: pr_status
run: |
if [[ "${{ github.event.action }}" == "opened" ]]; then
echo "status=🟢 Open" >> $GITHUB_ENV
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true" ]]; then
echo "status=🟣 Merged" >> $GITHUB_ENV
elif [[ "${{ github.event.action }}" == "closed" ]]; then
echo "status=🔴 Closed" >> $GITHUB_ENV
else
echo "status=🟢 Open" >> $GITHUB_ENV
fi
- name: Set PR_NOTIFICATION for Debugging
run: echo "PR_NOTIFICATION=${{ secrets.PR_NOTIFICATION }}" >> $GITHUB_ENV
- name: Check if PR_NOTIFICATION Secret is Set
run: |
if [[ -z "${PR_NOTIFICATION}" ]]; then
echo "PR_NOTIFICATION secret is not set."
else
echo "PR_NOTIFICATION secret is set."
fi
- name: Send notification to Google Chat
uses: fjogeleit/[email protected]
with:
url: ${{ secrets.PR_NOTIFICATION }}
method: POST
contentType: application/json
data: |
{
"cards": [
{
"header": {
"title": "Open source: Pull Request Opened by ${{ github.event.pull_request.user.login }}",
"subtitle": "Pull Request #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}",
"imageUrl": "${{ github.event.pull_request.user.avatar_url }}"
},
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": "Repository: ${{ github.repository }}"
}
},
{
"textParagraph": {
"text": "Status: ${{ env.status }}"
}
},
{
"buttons": [
{
"textButton": {
"text": "View Pull Request",
"onClick": {
"openLink": {
"url": "${{ github.event.pull_request.html_url }}"
}
}
}
}
]
}
]
}
]
}
]
}