-
Notifications
You must be signed in to change notification settings - Fork 181
124 lines (99 loc) · 4.34 KB
/
pattern-metrics.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
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
name: Monthly Metrics
on:
workflow_dispatch:
schedule:
- cron: '3 2 1 * *'
permissions:
issues: write
pull-requests: read
jobs:
issue-metrics:
name: issue metrics
runs-on: ubuntu-latest
steps:
- name: Get dates for last month
shell: bash
run: |
# Calculate the first day of the previous month
first_day=$(date -d "last month" +%Y-%m-01)
# Calculate the last day of the previous month
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d)
#Set an environment variable with the date range
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"
- name: Check out the code so we can get the CODEOWNERS names
uses: actions/checkout@v4
with:
sparse-checkout: |
.github/CODEOWNERS
sparse-checkout-cone-mode: false
- name: Get usernames from CODEOWNERS file
shell: bash
run: |
# open a file called CODEOWNERS and load the content into a variable
CODEOWNERS_FILE=$(cat .github/CODEOWNERS)
# Extract words from CODEOWNERS that start with @ and convert them into a comma-separated string
# ie, "-author:spier -author:zkoppert"
# This will be used to filter out these codeowners from certain stats in later steps
CODEOWNERS_FILTER=$(echo $CODEOWNERS_FILE | grep -o "@[a-zA-Z0-9\-]*" | sed 's/@/-author:/g' | tr '\n' ' ')
# Print usernames to terminal for easy debugging
echo "CODEOWNERS_FILTER: $CODEOWNERS_FILTER"
# Store CODEOWNERS_FILTERto GitHub Action environment (not permanent)
echo "CODEOWNERS_FILTER=$CODEOWNERS_FILTER" >> "$GITHUB_ENV"
- name: Run issue-metrics tool
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:InnerSourceCommons/InnerSourcePatterns is:issue created:${{ env.last_month }} -reason:"not planned" ${{ env.CODEOWNERS_FILTER }}'
HIDE_TIME_TO_ANSWER: "True"
HIDE_LABEL_METRICS: "True"
- name: Create issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Monthly New Issues Data ${{ env.last_month }}
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
assignees: spier
pr-metrics:
name: pull request metrics
runs-on: ubuntu-latest
steps:
- name: Get dates for last month
shell: bash
run: |
# Calculate the first day of the previous month
first_day=$(date -d "last month" +%Y-%m-01)
# Calculate the last day of the previous month
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d)
#Set an environment variable with the date range
echo "$first_day..$last_day"
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV"
- name: Check out the code so we can get the CODEOWNERS names
uses: actions/checkout@v4
- name: Get usernames from CODEOWNERS file
shell: bash
run: |
# open a file called CODEOWNERS and load the content into a variable
CODEOWNERS_FILE=$(cat .github/CODEOWNERS)
# Extract words from CODEOWNERS that start with @ and convert them into a comma-separated string
# ie, "-author:spier -author:zkoppert"
# This will be used to filter out these codeowners from certain stats in later steps
CODEOWNERS_FILTER=$(echo $CODEOWNERS_FILE | grep -o "@[a-zA-Z0-9\-]*" | sed 's/@/-author:/g' | tr '\n' ' ')
# Print usernames to terminal for easy debugging
echo "CODEOWNERS_FILTER: $CODEOWNERS_FILTER"
# Store CODEOWNERS_FILTERto GitHub Action environment (not permanent)
echo "CODEOWNERS_FILTER=$CODEOWNERS_FILTER" >> "$GITHUB_ENV"
- name: Run issue-metrics tool
uses: github/issue-metrics@v2
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEARCH_QUERY: 'repo:InnerSourceCommons/InnerSourcePatterns is:pr created:${{ env.last_month }} -reason:"not planned" ${{ env.CODEOWNERS_FILTER }}'
HIDE_TIME_TO_ANSWER: "True"
HIDE_LABEL_METRICS: "True"
- name: Create issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Monthly New Pull Request Data ${{ env.last_month }}
token: ${{ secrets.GITHUB_TOKEN }}
content-filepath: ./issue_metrics.md
assignees: spier