-
-
Notifications
You must be signed in to change notification settings - Fork 5
69 lines (64 loc) · 2.51 KB
/
analytics.yml
File metadata and controls
69 lines (64 loc) · 2.51 KB
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
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
# Update Ultralytics Analytics
#
# This workflow collects public analytics data for the Ultralytics organization:
#
# GitHub Data (data/github.json):
# - Repository star counts, fork counts, issues, and PRs across all public repos
# - Contributor counts per repository
# - Organization-wide totals and timestamps
#
# PyPI Data (data/pypi.json):
# - All-time total downloads per package and org-wide (via pepy.tech API with auth)
# - Daily, weekly, and monthly download counts (via pypistats.org API)
# - Tracked packages: ultralytics, ultralytics-actions, ultralytics-thop,
# hub-sdk, mkdocs-ultralytics-plugin, ultralytics-autoimport
#
# Google Analytics Data (data/google_analytics.json):
# - Active users, sessions, and page views (30-day window)
# - Requires GA_CREDENTIALS_JSON secret
#
# All data is publicly available via GitHub API, pypistats.org API, and pepy.tech API.
# Note: pepy.tech requires API key (set PEPY_API_KEY secret in repo settings).
# Results are committed daily to main branch via automated PR.
name: Update Analytics
on:
schedule:
- cron: "7 2 * * *" # daily at 02:07 UTC
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
stats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- uses: astral-sh/setup-uv@v7
- run: uv pip install --system -r requirements.txt
- name: Fetch analytics
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PEPY_API_KEY: ${{ secrets.PEPY_API_KEY }}
GA_CREDENTIALS_JSON: ${{ secrets.GA_CREDENTIALS_JSON }}
run: python fetch_stats.py
- name: Create PR and merge
env:
GH_TOKEN: ${{ secrets._GITHUB_TOKEN }}
run: |
if [[ -n "$(git status --porcelain)" ]]; then
BRANCH="analytics-$(date +%s)"
git config user.name "UltralyticsAssistant"
git config user.email "web@ultralytics.com"
git checkout -b "$BRANCH"
git add data/
git commit -m "Update analytics data"
git push origin "$BRANCH"
gh pr create --title "Update Ultralytics analytics" --body "Automated daily analytics update" --base main --head "$BRANCH"
PR_NUMBER=$(gh pr view "$BRANCH" --json number -q .number)
sleep 300
gh pr merge "$PR_NUMBER" --squash --delete-branch --admin
fi