feat: aggiunta generazione immagine OG per la pagina Numeri e aggiorn… #118
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: Deploy to GitHub Pages | |
| on: | |
| # Trigger su push al branch main | |
| push: | |
| branches: [ main ] | |
| # Deploy automatico 5 volte al giorno: 8:00, 12:00, 16:00, 19:30, 20:00 UTC | |
| # 21:30 UTC = 23:30 ora italiana (considerando ora legale) | |
| schedule: | |
| - cron: '0 8,12,16,20 * * *' | |
| - cron: '30 21 * * *' | |
| # Permetti di lanciare manualmente dalla UI GitHub | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: 'Motivo del deploy manuale' | |
| required: false | |
| default: 'Deploy manuale' | |
| # Permessi necessari per il deploy | |
| permissions: | |
| contents: write # Necessario per commit e push | |
| pages: write | |
| id-token: write | |
| # Consenti solo un deployment alla volta | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Show manual deploy reason | |
| if: github.event_name == 'workflow_dispatch' | |
| run: echo "Deploy manuale lanciato - Motivo:" "${{ github.event.inputs.reason }}" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm install --legacy-peer-deps | |
| - name: Install dependencies for data processing | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y jq miller | |
| - name: Download and save API data | |
| run: | | |
| # Rendi eseguibile lo script di download | |
| chmod +x scripts/download_data.sh | |
| # Esegui lo script di download | |
| ./scripts/download_data.sh | |
| # Crea il file check_date.txt con la data di scarico | |
| date '+%Y-%m-%d' > data/check_date.txt | |
| echo "📅 Created check_date.txt with download date: $(cat data/check_date.txt)" | |
| - name: Commit and push updated data | |
| run: | | |
| # Configura git | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| # Aggiungi i file se sono cambiati | |
| git add data/source.json data/source.jsonl data/time_line.jsonl data/media_sostenitori_giornaliera.jsonl data/check_date.txt | |
| # Verifica se ci sono cambiamenti da committare | |
| if git diff --staged --quiet; then | |
| echo "📝 No changes in data files" | |
| else | |
| echo "📝 Committing updated data files" | |
| git commit -m "chore: update data files with latest API data [skip ci]" | |
| git push | |
| fi | |
| - name: Generate Open Graph Images | |
| run: npm run generate-og-images | |
| - name: Build with Astro | |
| run: npm run build | |
| env: | |
| NODE_ENV: production | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| with: | |
| # Abilita automaticamente Pages se non è già abilitato | |
| enablement: true | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './dist' | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |