Skip to content

Commit 085d48a

Browse files
committed
Create GH workflow to generate github metrics
1 parent 253652d commit 085d48a

File tree

1 file changed

+282
-0
lines changed

1 file changed

+282
-0
lines changed

.github/workflows/github-metrics.yml

+282
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
name: GitHub Metrics
2+
3+
# on:
4+
# workflow_dispatch:
5+
# schedule:
6+
# - cron: '3 2 1 * *'
7+
on: [pull_request]
8+
9+
jobs:
10+
get_dates:
11+
name: Get Dates
12+
runs-on: ubuntu-latest
13+
outputs:
14+
report_month: ${{ steps.get_dates.outputs.report_month }}
15+
last_month: ${{ steps.get_dates.outputs.last_month }}
16+
steps:
17+
- id: get_dates
18+
name: Get dates for last month
19+
shell: bash
20+
run: |
21+
# Get the current date
22+
current_date=$(date +'%Y-%m-%d')
23+
24+
# Calculate the previous month
25+
previous_date=$(date -d "$current_date -1 month" +'%Y-%m-%d')
26+
27+
# Put the report month and year in the environment
28+
echo report_month="$(date -d "$previous_date" +'%B') $(date -d "$previous_date" +'%Y')" >> "$GITHUB_OUTPUT"
29+
30+
# Extract the year and month from the previous date
31+
previous_year=$(date -d "$previous_date" +'%Y')
32+
previous_month=$(date -d "$previous_date" +'%m')
33+
34+
# Calculate the first day of the previous month
35+
first_day=$(date -d "$previous_year-$previous_month-01" +'%Y-%m-%d')
36+
37+
# Calculate the last day of the previous month
38+
last_day=$(date -d "$first_day +1 month -1 day" +'%Y-%m-%d')
39+
40+
echo "$first_day..$last_day"
41+
echo "last_month=$first_day..$last_day" >> "$GITHUB_OUTPUT"
42+
43+
# Issues
44+
issues_opened:
45+
name: Issues Opened
46+
runs-on: ubuntu-latest
47+
needs: get_dates
48+
steps:
49+
- name: Run issue-metrics tool for issues opened last month
50+
uses: github/issue-metrics@v2
51+
env:
52+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
53+
SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:issue created:${{ needs.get_dates.outputs.last_month }}'
54+
HIDE_TIME_TO_ANSWER: true
55+
56+
- id: create_issue
57+
name: Create issue
58+
uses: peter-evans/create-issue-from-file@v4
59+
with:
60+
title: Issues Opened in ${{ needs.get_dates.outputs.report_month }}
61+
content-filepath: ./issue_metrics.md
62+
63+
- id: comment_issue
64+
name: Prepare JSON comment
65+
uses: peter-evans/create-or-update-comment@v3
66+
with:
67+
issue-number: ${{ steps.create_issue.outputs.issue-number }}
68+
body: "```json"
69+
70+
- name: Attach JSON
71+
uses: peter-evans/create-or-update-comment@v3
72+
with:
73+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
74+
body-path: ./issue_metrics.json
75+
edit-mode: append
76+
77+
- name: Finish JSON comment
78+
uses: peter-evans/create-or-update-comment@v3
79+
with:
80+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
81+
body: "```"
82+
edit-mode: append
83+
84+
issues_closed:
85+
name: Issues Closed
86+
runs-on: ubuntu-latest
87+
needs: get_dates
88+
steps:
89+
- name: Run issue-metrics tool for issues closed last month
90+
uses: github/issue-metrics@v2
91+
env:
92+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
93+
SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:issue closed:${{ needs.get_dates.outputs.last_month }}'
94+
HIDE_TIME_TO_ANSWER: true
95+
96+
- id: create_issue
97+
name: Create issue
98+
uses: peter-evans/create-issue-from-file@v4
99+
with:
100+
title: Issues Closed in ${{ needs.get_dates.outputs.report_month }}
101+
content-filepath: ./issue_metrics.md
102+
103+
- id: comment_issue
104+
name: Prepare JSON comment
105+
uses: peter-evans/create-or-update-comment@v3
106+
with:
107+
issue-number: ${{ steps.create_issue.outputs.issue-number }}
108+
body: "```json"
109+
110+
- name: Attach JSON
111+
uses: peter-evans/create-or-update-comment@v3
112+
with:
113+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
114+
body-path: ./issue_metrics.json
115+
edit-mode: append
116+
117+
- name: Finish JSON comment
118+
uses: peter-evans/create-or-update-comment@v3
119+
with:
120+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
121+
body: "```"
122+
edit-mode: append
123+
124+
# PRs
125+
prs_opened:
126+
name: PRs Opened
127+
runs-on: ubuntu-latest
128+
needs: get_dates
129+
steps:
130+
- name: Run issue-metrics tool for PRs opened last month
131+
uses: github/issue-metrics@v2
132+
env:
133+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
134+
SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:pull-request created:${{ needs.get_dates.outputs.last_month }}'
135+
HIDE_TIME_TO_ANSWER: true
136+
137+
- id: create_issue
138+
name: Create issue
139+
uses: peter-evans/create-issue-from-file@v4
140+
with:
141+
title: PRs Opened in ${{ needs.get_dates.outputs.report_month }}
142+
content-filepath: ./issue_metrics.md
143+
144+
- id: comment_issue
145+
name: Prepare JSON comment
146+
uses: peter-evans/create-or-update-comment@v3
147+
with:
148+
issue-number: ${{ steps.create_issue.outputs.issue-number }}
149+
body: "```json"
150+
151+
- name: Attach JSON
152+
uses: peter-evans/create-or-update-comment@v3
153+
with:
154+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
155+
body-path: ./issue_metrics.json
156+
edit-mode: append
157+
158+
- name: Finish JSON comment
159+
uses: peter-evans/create-or-update-comment@v3
160+
with:
161+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
162+
body: "```"
163+
edit-mode: append
164+
165+
prs_closed:
166+
name: PRs Closed
167+
runs-on: ubuntu-latest
168+
needs: get_dates
169+
steps:
170+
- name: Run issue-metrics tool for PRs closed last month
171+
uses: github/issue-metrics@v2
172+
env:
173+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
174+
SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php is:pull-request closed:${{ needs.get_dates.outputs.last_month }}'
175+
HIDE_TIME_TO_ANSWER: true
176+
177+
- id: create_issue
178+
name: Create issue
179+
uses: peter-evans/create-issue-from-file@v4
180+
with:
181+
title: PRs Closed in ${{ needs.get_dates.outputs.report_month }}
182+
content-filepath: ./issue_metrics.md
183+
184+
- id: comment_issue
185+
name: Prepare JSON comment
186+
uses: peter-evans/create-or-update-comment@v3
187+
with:
188+
issue-number: ${{ steps.create_issue.outputs.issue-number }}
189+
body: "```json"
190+
191+
- name: Attach JSON
192+
uses: peter-evans/create-or-update-comment@v3
193+
with:
194+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
195+
body-path: ./issue_metrics.json
196+
edit-mode: append
197+
198+
- name: Finish JSON comment
199+
uses: peter-evans/create-or-update-comment@v3
200+
with:
201+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
202+
body: "```"
203+
edit-mode: append
204+
205+
# Discussions
206+
discussions_opened:
207+
name: Discussions Opened
208+
runs-on: ubuntu-latest
209+
needs: get_dates
210+
steps:
211+
- name: Run issue-metrics tool for discussions opened last month
212+
uses: github/issue-metrics@v2
213+
env:
214+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
215+
SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php type:discussions created:${{ needs.get_dates.outputs.last_month }}'
216+
217+
- id: create_issue
218+
name: Create issue
219+
uses: peter-evans/create-issue-from-file@v4
220+
with:
221+
title: Discussions Opened in ${{ needs.get_dates.outputs.report_month }}
222+
content-filepath: ./issue_metrics.md
223+
224+
- id: comment_issue
225+
name: Prepare JSON comment
226+
uses: peter-evans/create-or-update-comment@v3
227+
with:
228+
issue-number: ${{ steps.create_issue.outputs.issue-number }}
229+
body: "```json"
230+
231+
- name: Attach JSON
232+
uses: peter-evans/create-or-update-comment@v3
233+
with:
234+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
235+
body-path: ./issue_metrics.json
236+
edit-mode: append
237+
238+
- name: Finish JSON comment
239+
uses: peter-evans/create-or-update-comment@v3
240+
with:
241+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
242+
body: "```"
243+
edit-mode: append
244+
245+
discussions_closed:
246+
name: Discussions Closed
247+
runs-on: ubuntu-latest
248+
needs: get_dates
249+
steps:
250+
- name: Run issue-metrics tool for discussions closed last month
251+
uses: github/issue-metrics@v2
252+
env:
253+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
254+
SEARCH_QUERY: 'org:appwrite org:open-runtimes org:utopia-php type:discussions closed:${{ needs.get_dates.outputs.last_month }}'
255+
256+
- id: create_issue
257+
name: Create issue
258+
uses: peter-evans/create-issue-from-file@v4
259+
with:
260+
title: Discussions Closed in ${{ needs.get_dates.outputs.report_month }}
261+
content-filepath: ./issue_metrics.md
262+
263+
- id: comment_issue
264+
name: Prepare JSON comment
265+
uses: peter-evans/create-or-update-comment@v3
266+
with:
267+
issue-number: ${{ steps.create_issue.outputs.issue-number }}
268+
body: "```json"
269+
270+
- name: Attach JSON
271+
uses: peter-evans/create-or-update-comment@v3
272+
with:
273+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
274+
body-path: ./issue_metrics.json
275+
edit-mode: append
276+
277+
- name: Finish JSON comment
278+
uses: peter-evans/create-or-update-comment@v3
279+
with:
280+
comment-id: ${{ steps.comment_issue.outputs.comment-id }}
281+
body: "```"
282+
edit-mode: append

0 commit comments

Comments
 (0)