Skip to content

Commit d9c648e

Browse files
committed
chore: update workflow
1 parent b8f52dc commit d9c648e

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Update All Data
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * 1' # Run weekly on Monday at 00:00 UTC
7+
8+
concurrency:
9+
group: 'data-update'
10+
cancel-in-progress: false
11+
12+
jobs:
13+
update-all:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0 # Fetch full history for git diff
23+
24+
- name: Install pnpm
25+
uses: pnpm/action-setup@v3
26+
with:
27+
version: 8
28+
29+
- name: Install Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
cache: pnpm
34+
35+
- name: Install dependencies
36+
run: pnpm install
37+
38+
- name: Install wrangler
39+
run: pnpm i -D wrangler@latest
40+
41+
- name: Setup Python
42+
uses: actions/setup-python@v4
43+
with:
44+
python-version: '3.11'
45+
46+
- name: Install Python dependencies
47+
run: |
48+
cd scripts
49+
pip install -r requirements.txt
50+
pip install requests
51+
52+
- 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
56+
env:
57+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
58+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
59+
60+
- name: Update Typesense Index
61+
env:
62+
TYPESENSE_API_KEY: ${{ secrets.PRIVATE_TYPESENSE_API_KEY }}
63+
TYPESENSE_HOST: ${{ secrets.TYPESENSE_HOST }}
64+
TYPESENSE_PROTOCOL: ${{ secrets.TYPESENSE_PROTOCOL }}
65+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
66+
run: |
67+
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
70+
if [ -f "src/lib/data/data.csv" ]; then
71+
python3 scripts/search_sync.py src/lib/data/data.csv "$TYPESENSE_PROTOCOL" "$TYPESENSE_HOST" "$TYPESENSE_API_KEY"
72+
echo "✅ Typesense update completed"
73+
else
74+
echo "❌ src/lib/data/data.csv not found!"
75+
exit 1
76+
fi
77+
78+
- name: Commit and Push Changes
79+
run: |
80+
git config --global user.name 'github-actions[bot]'
81+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
82+
83+
# Add specific files
84+
git add src/lib/data/data.csv static/recent_updates.json
85+
86+
# Check if there are changes
87+
if git diff --staged --quiet; then
88+
echo "No changes to commit"
89+
else
90+
git commit -m "chore: update data and recent updates [skip ci]"
91+
git push
92+
fi

0 commit comments

Comments
 (0)