Nightly Workshop Data Update and Site Rebuild #169
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: Nightly Workshop Data Update and Site Rebuild | |
| on: | |
| schedule: | |
| # Run daily at 7:30 AM UTC (12:30 AM PST) - 26 minutes after Google Sheets update | |
| - cron: '30 7 * * *' | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "nightly-update" | |
| cancel-in-progress: false | |
| jobs: | |
| update-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| # Setup Python for data fetching | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| # Step 1: Update workshop catalog from Google Sheets (fetch definitions first) | |
| - name: Fetch workshop catalog from Google Sheets | |
| env: | |
| GOOGLE_WORKSHOPS_SHEET_ID: ${{ secrets.GOOGLE_WORKSHOPS_SHEET_ID }} | |
| GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} | |
| run: | | |
| echo "Fetching workshop catalog..." | |
| python scripts/fetch_workshop_catalog.py | |
| echo "Workshop catalog fetch completed" | |
| # Step 2: Update workshop data from Google Sheets (fetch scheduled sessions) | |
| - name: Fetch workshop data from Google Sheets | |
| env: | |
| GOOGLE_SHEET_ID: ${{ secrets.GOOGLE_SHEET_ID }} | |
| GOOGLE_SERVICE_ACCOUNT_KEY: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }} | |
| GOOGLE_WORKSHOPS_SHEET_ID: ${{ secrets.GOOGLE_WORKSHOPS_SHEET_ID }} | |
| run: | | |
| echo "Fetching workshop data..." | |
| python scripts/fetch_google_sheets.py | |
| echo "Workshop data fetch completed" | |
| # Step 3: Generate workshop pages for new workshops | |
| - name: Generate workshop pages for new workshops | |
| run: | | |
| echo "Generating workshop pages..." | |
| python scripts/generate_workshop_pages.py | |
| echo "Workshop page generation completed" | |
| # Step 4: Commit data changes | |
| - name: Commit workshop data changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add _data/upcoming_workshops.json _data/workshops.yml workshop/ | |
| if git diff --staged --quiet; then | |
| echo "No workshop data changes to commit" | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| git commit -m "Nightly update: workshop data and catalog $(date -u '+%Y-%m-%d %H:%M UTC')" | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| echo "Workshop data changes committed" | |
| fi | |
| id: commit_data | |
| # Step 5: Setup Ruby and Jekyll (only if we have changes or it's a scheduled run) | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.4' | |
| bundler-cache: true | |
| - name: Install Jekyll dependencies | |
| run: bundle install | |
| # Step 6: Setup GitHub Pages | |
| - name: Setup Pages | |
| id: pages | |
| uses: actions/configure-pages@v4 | |
| # Step 7: Build Jekyll site | |
| - name: Build with Jekyll | |
| run: | | |
| echo "Building Jekyll site..." | |
| bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" | |
| echo "Jekyll build completed" | |
| env: | |
| JEKYLL_ENV: production | |
| # Step 8: Upload and deploy to GitHub Pages | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # Step 9: Push data changes to repository (after successful deployment) | |
| - name: Push changes to repository | |
| if: steps.commit_data.outputs.has_changes == 'true' | |
| run: | | |
| echo "Pushing changes to repository..." | |
| git push | |
| echo "Changes pushed successfully" | |
| # Step 10: Summary | |
| - name: Workflow Summary | |
| run: | | |
| echo "🎉 Nightly update completed successfully!" | |
| echo "📊 Data updated: ${{ steps.commit_data.outputs.has_changes }}" | |
| echo "🚀 Site deployed to: ${{ steps.deployment.outputs.page_url }}" | |
| echo "⏰ Completed at: $(date -u '+%Y-%m-%d %H:%M UTC')" |