forked from jthornber/dmtest-python
-
Notifications
You must be signed in to change notification settings - Fork 5
149 lines (139 loc) · 5.99 KB
/
notify.yml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Notify
on:
schedule:
- cron: '17 0 * * 1'
# '0 0,2,10,12,14,16,18,20,22 * * 1-5'
workflow_dispatch:
jobs:
notify_schedule:
env:
ORG: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
runs-on: ubuntu-latest
steps:
- name: Notify PRs No Status
uses: octokit/[email protected]
id: prs_no_status
with:
query: |
query needreview($queryString:String!) {
search(type: ISSUE, query: $queryString, last: 100) {
issueCount
}
}
variables: |
queryString: "repo:${{ env.ORG }}/${{env.REPO}}, state:open, is:pr, -label:\"on hold\", draft:false, review:none,"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify PRs Needing Review
uses: octokit/[email protected]
id: prs_need_review
with:
query: |
query needreview($queryString:String!) {
search(type: ISSUE, query: $queryString, last: 100) {
issueCount
}
}
variables: |
queryString: "repo:${{ env.ORG }}/${{env.REPO}}, state:open, is:pr, -label:\"on hold\", draft:false, review:required,"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: slackapi/[email protected]
if: 0
# ${{ env.COUNT > 0 }}
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"PR_MSG": "Number of PRs awaiting reviews in ${{env.REPO}} : ${{ env.COUNT }}",
"PR_LINK": "https://github.com/${{env.ORG}}/${{env.REPO}}/pulls?q=is%3Apr+is%3Aopen+-label%3A%22on%20hold%22+draft%3Afalse+review%3Arequired"
}
env:
COUNT: ${{ fromJSON(steps.prs_need_review.outputs.data).search.issueCount }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACKMSG }}
- name: Notify PRs With Feedback
uses: octokit/[email protected]
id: prs_with_feedback
with:
query: |
query withfeedback($queryString:String!) {
search(type: ISSUE, query: $queryString, last: 100) {
issueCount
}
}
variables: |
queryString: "repo:${{env.ORG}}/${{env.REPO}}, state:open, is:pr, -label:\"on hold\", draft:false, review:changes_requested,"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: slackapi/[email protected]
if: 0
# ${{ env.COUNT > 0 }}
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"PR_MSG": "Number of PRs awaiting replies to reviews ${{env.REPO}} : ${{ env.COUNT }}",
"PR_LINK": "https://github.com/${{env.ORG}}/${{env.REPO}}/pulls?q=is%3Apr+is%3Aopen+-label%3A%22on%20hold%22+draft%3Afalse+review%3Achanges_requested"
}
env:
COUNT: ${{ fromJSON(steps.prs_with_feedback.outputs.data).search.issueCount }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACKMSG }}
- name: Notify PRs With Approval
uses: octokit/[email protected]
id: prs_with_approval
with:
query: |
query withapproval($queryString:String!) {
search(type: ISSUE, query: $queryString, last: 100) {
issueCount
}
}
variables: |
queryString: "repo:${{env.ORG}}/${{env.REPO}}, state:open, is:pr, -label:\"on hold\", draft:false, review:approved,"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: slackapi/[email protected]
if: 0
# ${{ env.COUNT > 0 }}
with:
# This data can be any valid JSON from a previous step in the GitHub Action
payload: |
{
"PR_MSG": "Number of PRs approved in ${{env.REPO}} : ${{ env.COUNT }}",
"PR_LINK": "https://github.com/${{env.ORG}}/${{env.REPO}}/pulls?q=is%3Apr+is%3Aopen+-label%3A%22on%20hold%22+draft%3Afalse+review%3Aapproved"
}
env:
COUNT: ${{ fromJSON(steps.prs_with_approval.outputs.data).search.issueCount }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACKMSG }}
- name: Format Message
id: format_message
run: |
echo -n MESSAGE=${{ env.REPO }} PRs >> $GITHUB_OUTPUT
first=true
if test ${{ env.COUNT_OPEN }} -gt 0; then
if $first; then first=false; else echo -n , >> $GITHUB_OUTPUT; fi
echo -n " newly opened: ${{ env.COUNT_OPEN }}" >> $GITHUB_OUTPUT
fi
if test ${{ env.COUNT_NEED_REVIEW }} -gt 0; then
if $first; then first=false; else echo -n , >> $GITHUB_OUTPUT; fi
echo -n " needing reviews: ${{ env.COUNT_NEED_REVIEW }}" >> $GITHUB_OUTPUT
fi
if test ${{ env.COUNT_WITH_FEEDBACK }} -gt 0; then
if $first; then first=false; else echo -n , >> $GITHUB_OUTPUT; fi
echo -n " awaiting replies to reviews: ${{ env.COUNT_WITH_FEEDBACK }}" >> $GITHUB_OUTPUT
fi
if test ${{ env.COUNT_WITH_APPROVAL }} -gt 0; then
if $first; then first=false; else echo -n , >> $GITHUB_OUTPUT; fi
echo -n " approved: ${{ env.COUNT_WITH_APPROVAL }}" >> $GITHUB_OUTPUT
fi
echo . >> $GITHUB_OUTPUT
env:
COUNT_OPEN: ${{ fromJSON(steps.prs_no_status.outputs.data).search.issueCount }}
COUNT_NEED_REVIEW: ${{ fromJSON(steps.prs_need_review.outputs.data).search.issueCount }}
COUNT_WITH_FEEDBACK: ${{ fromJSON(steps.prs_with_feedback.outputs.data).search.issueCount }}
COUNT_WITH_APPROVAL: ${{ fromJSON(steps.prs_with_approval.outputs.data).search.issueCount }}
- name: Show message
run: echo ${{ env.MSG }}
env:
MSG: ${{ steps.format_message.outputs.MESSAGE }}