mirror of
https://github.com/blackboxprogramming/blackroad-os-kpis.git
synced 2026-03-17 06:57:14 -05:00
79 lines
2.6 KiB
YAML
79 lines
2.6 KiB
YAML
name: Daily KPI Collection
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 6 * * *'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
collect:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: Collect GitHub KPIs
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
run: bash collectors/github.sh
|
|
|
|
- name: Generate daily aggregate
|
|
run: |
|
|
TODAY=$(date +%Y-%m-%d)
|
|
NOW=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
python3 -c "
|
|
import json, glob, os
|
|
today = '$TODAY'
|
|
data_dir = 'data'
|
|
os.makedirs(f'{data_dir}/daily', exist_ok=True)
|
|
snapshots = {}
|
|
for f in glob.glob(f'{data_dir}/snapshots/{today}-*.json'):
|
|
source = os.path.basename(f).replace(f'{today}-', '').replace('.json', '')
|
|
with open(f) as fh:
|
|
snapshots[source] = json.load(fh)
|
|
gh = snapshots.get('github', {})
|
|
daily = {
|
|
'date': today,
|
|
'collected_at': '$NOW',
|
|
'summary': {
|
|
'commits_today': gh.get('commits', {}).get('today', 0),
|
|
'prs_open': gh.get('pull_requests', {}).get('open', 0),
|
|
'prs_merged_today': gh.get('pull_requests', {}).get('merged_today', 0),
|
|
'prs_merged_total': gh.get('pull_requests', {}).get('merged_total', 0),
|
|
'repos_github': gh.get('repos', {}).get('total', 0),
|
|
'repos_gitea': 0,
|
|
'repos_total': gh.get('repos', {}).get('total', 0),
|
|
'fleet_online': 0, 'fleet_total': 4,
|
|
'autonomy_score': 0, 'total_loc': 0,
|
|
'docker_containers': 0, 'ollama_models': 0,
|
|
'avg_temp_c': 0, 'failed_units': 0, 'throttled_nodes': []
|
|
},
|
|
'sources': snapshots
|
|
}
|
|
with open(f'{data_dir}/daily/{today}.json', 'w') as f:
|
|
json.dump(daily, f, indent=2)
|
|
"
|
|
|
|
- name: Generate markdown report
|
|
run: bash reports/markdown-report.sh
|
|
|
|
- name: Post to Slack
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
if: env.SLACK_WEBHOOK_URL != ''
|
|
run: bash reports/slack-notify.sh
|
|
|
|
- name: Commit data
|
|
run: |
|
|
git config user.name "BlackRoad KPI Bot"
|
|
git config user.email "kpi@blackroad.io"
|
|
git add data/ LATEST.md
|
|
git diff --staged --quiet || git commit -m "kpi: daily collection $(date +%Y-%m-%d)"
|
|
git push |