-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (98 loc) · 3.26 KB
/
Copy pathdeploy.yml
File metadata and controls
119 lines (98 loc) · 3.26 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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/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