-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (60 loc) · 2.01 KB
/
generate-metrics.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
name: DORA Metrics Workflow
on:
workflow_dispatch:
inputs:
date_range:
description: 'Date range for metrics (format: YYYY-MM-DD..YYYY-MM-DD)'
required: false
json_file_path:
description: 'Path to the JSON file with repository names'
required: false
schedule:
- cron: '0 8 * * 0' # At 08:00 on Sunday
concurrency:
group: generate-metrics
cancel-in-progress: false
permissions: {}
jobs:
run_metrics:
permissions:
issues: write
contents: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
- name: Install dependencies
run: pip install -r requirements.txt
- name: Get current date
if: github.event.inputs.date_range == ''
id: date
run: echo "date=$(date -u +%Y-%m-%d)" >> $GITHUB_ENV
- name: Calculate date range for the last 7 days
if: github.event.inputs.date_range == ''
id: last-7-days
run: |
echo "start_date=$(date -u +%Y-%m-%d --date='7 days ago')" >> $GITHUB_ENV
- name: Run scripts and create issues
env:
ACCESS_TOKEN: ${{ secrets.DATA_PLATFORM_ROBOT_PAT }}
GH_TOKEN: ${{ github.token }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: |
for json_file in *.json; do
name=$(basename "$json_file" .json)
issue_title="📊 DORA Metrics for ${{ env.start_date }}..${{ env.date }} for $name"
issue_body=""
for script in cfr.py df.py ltfc.py mttr.py; do
python $script $json_file "${{ env.start_date }}..${{ env.date }}"
output=$(cat output.log)
rm output.log
metric=$(basename "$script" .py | tr '[:lower:]' '[:upper:]')
issue_body+="$output"
done
if [[ "${GITHUB_EVENT_NAME}" == "schedule" ]]; then
gh issue create --title "$issue_title" --body "$issue_body"
fi
done