@@ -3,6 +3,14 @@ name: Exportera till HTML och publicera till GitHub Pages
33on :
44 workflow_dispatch : # Tillåter manuell körning
55 inputs :
6+ html_source :
7+ description : ' HTML-källan: generera från JSON eller ladda från R2'
8+ required : false
9+ type : choice
10+ options :
11+ - generate
12+ - download
13+ default : ' generate'
614 source_ref :
715 description : ' Git ref att bygga från'
816 required : false
1321 type : string
1422 workflow_call : # Tillåter anrop från andra workflows
1523 inputs :
24+ html_source :
25+ required : false
26+ type : string
27+ default : ' generate'
1628 source_ref :
1729 required : false
1830 type : string
@@ -43,17 +55,52 @@ jobs:
4355 with :
4456 ref : ${{ inputs.source_ref || 'main' }}
4557
58+ - name : Download pre-built HTML from Cloudflare R2
59+ if : inputs.html_source == 'download'
60+ run : |
61+ echo "📥 Laddar ner färdiga HTML-filer från Cloudflare R2..."
62+
63+ # Configure AWS CLI for R2
64+ aws configure set aws_access_key_id ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
65+ aws configure set aws_secret_access_key ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
66+ aws configure set region us-east-1
67+ aws configure set output json
68+
69+ # Create output directory
70+ mkdir -p _site
71+
72+ # Download all HTML files from R2 HTMLEXPORT bucket
73+ echo "Syncing from bucket: ${{ vars.CLOUDFLARE_R2_HTMLEXPORT_BUCKET_NAME }}"
74+ aws s3 sync s3://${{ vars.CLOUDFLARE_R2_HTMLEXPORT_BUCKET_NAME }}/ _site/ \
75+ --endpoint-url https://${{ secrets.CLOUDFLARE_R2_ACCOUNT_ID }}.r2.cloudflarestorage.com \
76+ --delete
77+
78+ # Verify download
79+ if [ ! -d "_site" ] || [ -z "$(ls -A _site)" ]; then
80+ echo "::error::Failed to download HTML files from R2"
81+ exit 1
82+ fi
83+
84+ echo "✅ Downloaded HTML files from R2 HTMLEXPORT bucket"
85+ echo "Total files: $(find _site -type f | wc -l)"
86+ echo "Total size: $(du -sh _site | cut -f1)"
87+ env :
88+ AWS_DEFAULT_REGION : us-east-1
89+
4690 - name : Set up Python
91+ if : inputs.html_source == 'generate' || inputs.html_source == ''
4792 uses : actions/setup-python@v4
4893 with :
4994 python-version : ' 3.11'
5095
5196 - name : Install dependencies
97+ if : inputs.html_source == 'generate' || inputs.html_source == ''
5298 run : |
5399 python -m pip install --upgrade pip
54100 pip install -r requirements.txt
55101
56102 - name : Get JSON source files (from git or R2)
103+ if : inputs.html_source == 'generate' || inputs.html_source == ''
57104 run : |
58105 # Try to use JSON files from git first
59106 if [ -d "data/sfs_json" ] && [ -n "$(ls -A data/sfs_json 2>/dev/null)" ]; then
86133 AWS_DEFAULT_REGION : us-east-1
87134
88135 - name : Generate HTML export
136+ if : inputs.html_source == 'generate' || inputs.html_source == ''
89137 run : |
90138 # Skapa output-katalog för GitHub Pages
91139 mkdir -p _site
99147 PYTHONPATH : ${{ github.workspace }}
100148
101149 - name : Generate index pages for HTML export
150+ if : inputs.html_source == 'generate' || inputs.html_source == ''
102151 run : |
103152 python exporters/html/populate_index_pages.py --input data/sfs_json --output _site/index.html --limit 30
104153 python exporters/html/populate_index_pages.py --input data/sfs_json --output _site/latest.html --limit 10
@@ -114,7 +163,14 @@ jobs:
114163 run : |
115164 echo "HTML export completed at $(date)" > _site/last-update.txt
116165 echo "Published to GitHub Pages" >> _site/last-update.txt
117- echo "Index pages: index.html (30 senaste), latest.html (10 senaste)" >> _site/last-update.txt
166+
167+ if [ "${{ inputs.html_source }}" = "download" ]; then
168+ echo "Source: Pre-built HTML from Cloudflare R2" >> _site/last-update.txt
169+ echo "Bucket: ${{ vars.CLOUDFLARE_R2_HTMLEXPORT_BUCKET_NAME }}" >> _site/last-update.txt
170+ else
171+ echo "Source: Generated from JSON" >> _site/last-update.txt
172+ echo "Index pages: index.html (30 senaste), latest.html (10 senaste)" >> _site/last-update.txt
173+ fi
118174
119175 - name : Setup Pages
120176 uses : actions/configure-pages@v5
0 commit comments