Skip to content

Reload Courses Every 8 Hours #451

Reload Courses Every 8 Hours

Reload Courses Every 8 Hours #451

Workflow file for this run

name: Reload Courses Every 8 Hours
on:
schedule:
- cron: "0 */8 * * *" # Cada 8 horas
workflow_dispatch: # ✅ Permite ejecución manual
jobs:
reload:
runs-on: ubuntu-latest
steps:
- name: Reload courses via API
env:
API_SECRET: ${{ secrets.API_SECRET }}
run: |
# Capturar el cuerpo de la respuesta y el código HTTP por separado
response_body=$(curl -s -X GET \
-H "Authorization: Bearer $API_SECRET" \
-H "Accept: application/x-ndjson" \
-w "\n%{http_code}" \
https://buscaramos-v2-static-data.osuc.workers.dev/reload)
# Separar el cuerpo del código HTTP (última línea)
http_code=$(echo "$response_body" | tail -n1)
json_body=$(echo "$response_body" | sed '$d')
# Imprimir la respuesta JSON
echo "API Response:"
echo "$json_body" | jq '.' || echo "$json_body"
# Verificar el código HTTP
if [ "$http_code" -ne 200 ]; then
echo "API call failed with status code: $http_code"
exit 1
else
echo "Courses reloaded successfully"
fi