Skip to content

Commit d5b524a

Browse files
committed
perf: github action caching
1 parent 92c1dc3 commit d5b524a

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

.github/workflows/update-all-data.yml

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
name: Update All Data
2-
1+
name: Update All Data (Optimized)
32
on:
43
workflow_dispatch:
54
schedule:
6-
- cron: '0 0 * * 1' # Run weekly on Monday at 00:00 UTC
7-
5+
- cron: "0 0 * * 1"
86
concurrency:
9-
group: 'data-update'
7+
group: "data-update"
108
cancel-in-progress: false
119

1210
jobs:
1311
update-all:
1412
runs-on: ubuntu-latest
1513
permissions:
1614
contents: write
17-
1815
steps:
1916
- name: Checkout
2017
uses: actions/checkout@v4
2118
with:
22-
fetch-depth: 0 # Fetch full history for git diff
19+
fetch-depth: 0
2320

2421
- name: Install pnpm
2522
uses: pnpm/action-setup@v3
@@ -39,20 +36,19 @@ jobs:
3936
run: pnpm i -D wrangler@latest
4037

4138
- name: Setup Python
42-
uses: actions/setup-python@v4
39+
uses: actions/setup-python@v5
4340
with:
44-
python-version: '3.11'
41+
python-version: "3.11"
42+
cache: "pip"
43+
cache-dependency-path: "scripts/requirements.txt"
4544

4645
- name: Install Python dependencies
4746
run: |
4847
cd scripts
4948
pip install -r requirements.txt
50-
pip install requests
5149
5250
- name: Fetch data, Update D1, and Generate Recent Updates
53-
run: |
54-
# This script handles fetching data, generating recent_updates.json, and updating D1
55-
pnpm run update-data-remote
51+
run: pnpm run update-data-remote
5652
env:
5753
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
5854
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
@@ -65,8 +61,6 @@ jobs:
6561
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
6662
run: |
6763
echo "🚀 Starting Typesense update..."
68-
# Ensure data.csv is in the expected location (src/lib/data/data.csv)
69-
# data_import.py puts it there by default or we can check
7064
if [ -f "src/lib/data/data.csv" ]; then
7165
python3 scripts/search_sync.py src/lib/data/data.csv "$TYPESENSE_PROTOCOL" "$TYPESENSE_HOST" "$TYPESENSE_API_KEY"
7266
echo "✅ Typesense update completed"
@@ -78,12 +72,25 @@ jobs:
7872
- name: Setup R
7973
uses: r-lib/actions/setup-r@v2
8074
with:
81-
r-version: '4.3.0'
75+
r-version: "4.3.0"
76+
use-public-rspm: true
77+
78+
- name: Setup Pandoc
79+
uses: r-lib/actions/setup-pandoc@v2
80+
81+
- name: Cache R packages
82+
uses: actions/cache@v3
83+
with:
84+
path: ${{ env.R_LIBS_USER }}
85+
key: ${{ runner.os }}-r-4.3.0-tidyverse-${{ hashFiles('analysis/**') }}
86+
restore-keys: |
87+
${{ runner.os }}-r-4.3.0-tidyverse-
88+
${{ runner.os }}-r-4.3.0-
8289
8390
- name: Install R dependencies
8491
run: |
8592
cd analysis
86-
R -e "install.packages(c('rmarkdown', 'tidyverse', 'jsonlite', 'here'), repos='https://cloud.r-project.org')"
93+
R -e "install.packages(c('rmarkdown', 'tidyverse', 'jsonlite', 'here'), repos='https://packagemanager.posit.co/cran/__linux__/jammy/latest')"
8794
8895
- name: Build Notebook
8996
run: pnpm run build-notebook
@@ -92,11 +99,7 @@ jobs:
9299
run: |
93100
git config --global user.name 'github-actions[bot]'
94101
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
95-
96-
# Add specific files
97102
git add src/lib/data/data.csv static/recent_updates.json static/rss.xml static/notebook/index.html src/lib/data/charts/*.json
98-
99-
# Check if there are changes
100103
if git diff --staged --quiet; then
101104
echo "No changes to commit"
102105
else

0 commit comments

Comments
 (0)