Reload Courses Every 8 Hours #451
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |