Build and Deploy to GitHub Pages #188
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
| # filepath: .github/workflows/deploy.yml | |
| name: Build and Deploy to GitHub Pages | |
| on: | |
| # Run daily at 5:00 AM NZST (17:00 UTC) | |
| schedule: | |
| - cron: '0 17 * * *' | |
| # Run on push to main branch | |
| push: | |
| branches: [ main ] | |
| # Allow manual trigger | |
| workflow_dispatch: | |
| # Sets permissions for GitHub Pages deployment | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| actions: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Keep workflow alive | |
| uses: silverstripe/gha-keepalive@v1 | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: | | |
| echo "Installing build dependencies" | |
| npm ci | |
| - name: Build site | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "Building site for deployment" | |
| npm run build | |
| - name: Verify build output | |
| run: | | |
| echo "Verifying build output..." | |
| ls -la dist/ | |
| echo "✅ Build verification complete" | |
| - name: Setup GitHub Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './dist' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |