forked from hiero-hackers/analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (81 loc) · 3.31 KB
/
Copy pathupdate-analytics.yml
File metadata and controls
94 lines (81 loc) · 3.31 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
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
name: Refresh Analytics Data
on:
schedule:
# Every 5 days at 9 AM UTC. Keeps gaps under the 7-day cache-eviction
# window so the incremental dataset cache stays warm.
- cron: '0 9 */5 * *'
workflow_dispatch:
permissions:
contents: read
jobs:
refresh-data:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 #v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 #v7.0.0
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 #v8.3.2
with:
version: "latest"
- name: Install dependencies
run: uv sync
# Persist the incremental-fetch datasets across runs without committing
# them to git. A unique key per run always saves; restore-keys pulls the
# most recent prior dataset. If the cache is ever evicted, the pipeline's
# 30-day self-heal just does one full fetch, then resumes incrementally.
- name: Restore incremental datasets
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: outputs/data/datasets
key: analytics-datasets-${{ github.run_id }}
restore-keys: |
analytics-datasets-
- name: Run all analytics pipelines
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: uv run python -m hiero_analytics.run_all
# Only persist datasets when the run succeeds. Saving after a failed run
# would let a partial snapshot become the next incremental baseline
# (restore picks the most recent analytics-datasets- key); on failure we
# keep the last good cache and let the next run resume from it.
- name: Save incremental datasets
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: outputs/data/datasets
key: analytics-datasets-${{ github.run_id }}
# Publish the self-contained dashboard to GitHub Pages so anyone can view the
# latest refresh without cloning or regenerating. The HTML embeds every chart
# as base64, so the site is a single index.html.
- name: Assemble Pages site
run: |
mkdir -p _site
cp outputs/dashboard.html _site/index.html
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: _site
# Publish the freshly-built dashboard to GitHub Pages. Runs after the data refresh
# regardless of whether the data changed, so the public page always reflects the
# most recent run. Requires Pages "Source: GitHub Actions" to be enabled once in
# the repository settings.
deploy-pages:
name: Deploy dashboard to GitHub Pages
needs: refresh-data
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
concurrency:
group: pages
cancel-in-progress: false
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0