-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (45 loc) · 1.43 KB
/
compute-course-stats.yml
File metadata and controls
56 lines (45 loc) · 1.43 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
name: Compute Course Stats
on:
# Run twice daily at 6am and 6pm UTC
schedule:
- cron: '0 6,18 * * *'
# Allow manual trigger
workflow_dispatch:
jobs:
compute-stats:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: |
npm install -g tsx
npm install @supabase/supabase-js
- name: Compute course stats
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
run: npx tsx scripts/compute-course-stats.ts
- name: Compute global stats
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
run: npx tsx scripts/compute-global-stats.ts
- name: Commit and push if changed
run: |
git config user.name 'Christian Tran'
git config user.email 'ctran4347@gmail.com'
git add static/course-stats.json static/global-stats.json
if git diff --staged --quiet; then
echo "No changes to commit"
else
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
git commit -m "Update course stats $TIMESTAMP"
git push
fi