-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (37 loc) · 1.63 KB
/
Copy pathdaily-refresh.yml
File metadata and controls
39 lines (37 loc) · 1.63 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
# Rigenerazione giornaliera dei contenuti + giro di push.
#
# Il servizio si mantiene gia' da solo: un worker interno rigenera la cache una
# volta al giorno e si auto-pinga ogni 10 minuti (SELF_URL). Dall'esterno ci
# pensa anche keep-warm.yml, che gira ogni 10 minuti su tutte e tre le app.
#
# Questo workflow copre l'unico caso che il servizio non puo' coprire da solo:
# se l'istanza si e' comunque spenta, da spenta nessun worker interno gira.
# Qui la si sveglia e le si chiede esplicitamente il refresh del giorno.
#
# Setup (una volta sola): copia CRON_SECRET dalla dashboard Render in un secret
# del repository con lo stesso nome. Senza quel secret il job esce senza fare nulla.
name: Daily content refresh
on:
schedule:
- cron: "20 4 * * *" # 04:20 UTC — rebuild today's cache
- cron: "5 7 * * *" # 07:05 UTC — daily push round
workflow_dispatch:
jobs:
refresh:
runs-on: ubuntu-latest
steps:
- name: Wake the API and rebuild today's cache
env:
API_URL: https://accadde-oggi-api.onrender.com
CRON_SECRET: ${{ secrets.CRON_SECRET }}
run: |
if [ -z "$CRON_SECRET" ]; then
echo "CRON_SECRET secret is not set - nothing to do."
exit 0
fi
# A sleeping free instance needs a moment to boot before it answers.
curl -s -m 120 --retry 3 --retry-delay 20 "$API_URL/api/health" || true
curl -s -m 180 --retry 2 --retry-delay 30 \
-H "X-Cron-Key: $CRON_SECRET" "$API_URL/api/cron/daily" | head -c 2000
echo
curl -s -m 180 -H "X-Cron-Key: $CRON_SECRET" "$API_URL/api/cron/push" | head -c 2000