diff --git a/.github/workflows/deploy_to_pages.yml b/.github/workflows/deploy_to_pages.yml index 1fe829a4..61125629 100644 --- a/.github/workflows/deploy_to_pages.yml +++ b/.github/workflows/deploy_to_pages.yml @@ -26,8 +26,7 @@ jobs: - name: 🔧 Build & Test run: | - # Convert human-readable Geojson file into computer-friendly one - bundle exec rake compact_geojson + # Jekyll plugin automatically runs upsert_dojos_geojson, compact_geojson, and cache_dojo_logos JEKYLL_ENV=production bundle exec jekyll build JEKYLL_ENV=production bundle exec jekyll doctor SKIP_BUILD=true bundle exec rake test diff --git a/.github/workflows/scheduler_daily.yml b/.github/workflows/scheduler_daily.yml index f06fa899..9bc0c37e 100644 --- a/.github/workflows/scheduler_daily.yml +++ b/.github/workflows/scheduler_daily.yml @@ -51,14 +51,16 @@ jobs: run: | bundle exec rake get_data_from_japan - - name: ☯️ Cache dojo logos in Japan + - name: 🔧 Build data to render DojoMap run: | - bundle exec rake cache_dojo_logos + # Jekyll plugin automatically runs cache_dojo_logos, upsert_dojos_geojson, and compact_geojson + JEKYLL_ENV=production bundle exec jekyll build - - name: 📍 Generate DojoMap from Earth/Japan data + - name: ✅ Test run: | - bundle exec rake upsert_dojos_geojson - bundle exec rake compact_geojson + # _site is already built in previous step + JEKYLL_ENV=production bundle exec jekyll doctor + SKIP_BUILD=true bundle exec rake test - name: 🆙 Commit latest data to update DojoMap (if any) run: | @@ -87,14 +89,6 @@ jobs: env: GITHUB_TOKEN: - - name: 🔧 Build & Test - run: | - # Convert human-readable Geojson file into computer-friendly one - bundle exec rake compact_geojson - JEKYLL_ENV=production bundle exec jekyll build - JEKYLL_ENV=production bundle exec jekyll doctor - SKIP_BUILD=true bundle exec rake test - # This is NOT for security reason but for others, especially who fork, # to easier find out which API key they need to replace with their own. # Check out the official tutorial for details: https://docs.geolonia.com/tutorial diff --git a/_plugins/build_hooks.rb b/_plugins/build_hooks.rb new file mode 100644 index 00000000..cd62fdf7 --- /dev/null +++ b/_plugins/build_hooks.rb @@ -0,0 +1,18 @@ +# Pre-build tasks that run before Jekyll builds the site +Jekyll::Hooks.register :site, :after_init do |site| + puts "🔄 Running pre-build tasks..." + + # Update GeoJSON data + puts " → Updating dojos.geojson..." + system('bundle exec rake upsert_dojos_geojson') + + # Compact GeoJSON for production + puts " → Creating dojos.min.geojson..." + system('bundle exec rake compact_geojson') + + # Cache dojo logos + puts " → Caching dojo logos..." + system('bundle exec rake cache_dojo_logos') + + puts "✅ Pre-build tasks completed" +end