scarica bollettino ondata calore #4702
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: scarica bollettino ondata calore | |
| on: | |
| repository_dispatch: | |
| schedule: | |
| - cron: "3 8-15/1 * * *" | |
| - cron: "3 17 * * *" | |
| - cron: "3 19 * * *" | |
| - cron: "3 2 * * *" # 3:03 italiane (ora solare, 4:03 in ora legale) | |
| workflow_dispatch: | |
| jobs: | |
| scheduled: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout del repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configura l'ambiente Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| # cache: 'pip' | |
| - name: Installa dipendenze | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y software-properties-common gdal-bin | |
| pip install --upgrade pip | |
| pip install yq==3.4.3 xmltodict==0.13.0 | |
| npm i -g agent-browser | |
| agent-browser install | |
| - name: Prepara gli strumenti | |
| run: | | |
| mkdir -p ~/bin | |
| cp bin/scrape bin/mlr bin/mlrgo ~/bin/ | |
| chmod +x ~/bin/scrape ~/bin/mlr ~/bin/mlrgo | |
| echo "$HOME/bin" >> $GITHUB_PATH | |
| - name: Scarica i dati | |
| run: | | |
| chmod +x ./ondate-calore.sh | |
| ./ondate-calore.sh | |
| continue-on-error: false | |
| - name: Crea feed RSS | |
| run: | | |
| cd ./script | |
| chmod +x ./rss.sh | |
| ./rss.sh | |
| continue-on-error: false | |
| - name: Committa e pusha le modifiche | |
| run: | | |
| git config user.name "automatico" | |
| git config user.email "actions@users.noreply.github.com" | |
| git add -A | |
| timestamp=$(date --iso-8601=seconds) | |
| git commit -m "aggiornamento bollettino: ${timestamp}" || exit 0 | |
| git push | |
| - name: Attendi 10 secondi, aggiorna e ripubblica Datawrapper | |
| env: | |
| DW_TOKEN: ${{ secrets.ANDY_DATAWRAPPER_TOKEN_CHART_UPDATE }} | |
| DW_CHART: elo50 | |
| run: | | |
| sleep 10 | |
| # 1) refresh: ricarica i dati esterni nell'editor della mappa | |
| # -f fa fallire su HTTP >=400 (token scaduto/errori), -sS mostra il messaggio | |
| echo "Refresh dati mappa ${DW_CHART}..." | |
| curl -fsS -X POST "https://api.datawrapper.de/v3/charts/${DW_CHART}/data/refresh" \ | |
| -H "Authorization: Bearer ${DW_TOKEN}" | |
| echo | |
| # 2) publish: senza questo la mappa pubblica NON cambia (resta all'ultima versione) | |
| echo "Pubblico mappa ${DW_CHART}..." | |
| curl -fsS -X POST "https://api.datawrapper.de/v3/charts/${DW_CHART}/publish" \ | |
| -H "Authorization: Bearer ${DW_TOKEN}" | |
| echo |