-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (85 loc) · 3.34 KB
/
update-charts.yml
File metadata and controls
97 lines (85 loc) · 3.34 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
95
96
97
name: Update Charts
on:
# Trigger when data files land on main (after the data-update PR auto-merges).
# This replaces the old workflow_run trigger so sequencing is correct:
# data PR merges → push event fires → charts regenerate with fresh data.
push:
branches: [main]
paths:
- 'docs/data/**'
workflow_dispatch: # Allow manual trigger from GitHub UI
concurrency:
group: update-charts
cancel-in-progress: false
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
jobs:
update-charts:
runs-on: ubuntu-latest
permissions:
contents: write # to push branch
issues: write # to open failure issues
pull-requests: write # to create PR
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
- name: Install dependencies
run: pip install -r requirements-ci.txt
- name: Download AMEND database from GCS
run: curl -fsSL https://storage.googleapis.com/openamend-data/amend.db -o get_data/AMEND.db
- name: Generate dashboard charts
working-directory: analysis
run: python dashboard_charts.py
- name: Write dashboard update timestamp
run: |
echo "updated: $(date -u +'%Y-%m-%d %H:%M:%S')" > docs/data/ts_update_dashboard.yml
- name: Commit and open PR
env:
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/_includes/charts/dash_*.html \
docs/data/facts_dash_*.yml \
docs/data/facts_DEPstaff.yml \
docs/data/facts_DEPenforce.yml \
docs/data/facts_ECOSbudgets.yml \
docs/data/facts_EPA303d.yml \
docs/data/ts_update_dashboard.yml
if git diff --staged --quiet; then
echo "No chart changes — skipping PR."
exit 0
fi
BRANCH="auto/charts-$(date -u +%Y-%m-%d)"
git checkout -b "$BRANCH"
git commit -m "Auto-update dashboard charts $(date -u +%Y-%m-%d)"
git push origin "$BRANCH"
gh pr create \
--title "Auto-update dashboard charts $(date -u +%Y-%m-%d)" \
--body "Automated chart regeneration triggered by data update." \
--base main \
--head "$BRANCH"
gh pr merge "$BRANCH" --auto --squash
- name: Open issue on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Chart update failed: ${new Date().toISOString().split('T')[0]}`,
body: [
'## Chart generation failed',
'',
`**Run:** ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
'',
'Check the run logs above for details.',
'',
'Note: NECIR_CSO_map.py (PySTAN regression) is intentionally excluded from CI — run it locally.',
].join('\n'),
labels: ['chart-update-failure'],
})