Deploy to GitHub Pages #1697
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: Deploy to GitHub Pages | |
| on: | |
| # Trigger on push to main branch | |
| push: | |
| branches: | |
| - main | |
| # Trigger hourly to fetch fresh data from Google Sheets | |
| schedule: | |
| - cron: '0 * * * *' # Every hour at minute 0 | |
| # Allow manual trigger from GitHub UI | |
| workflow_dispatch: | |
| # Sets permissions for GitHub Pages deployment | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment | |
| 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: 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: npm ci | |
| - name: Build static site | |
| run: npm run build | |
| env: | |
| # GitHub token for higher API rate limits (uses built-in GITHUB_TOKEN) | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Add any other required environment variables here | |
| # Example: GOOGLE_SHEETS_API_KEY: ${{ secrets.GOOGLE_SHEETS_API_KEY }} | |
| - name: Create .nojekyll and CNAME files | |
| run: | | |
| touch out/.nojekyll | |
| echo "community.trainwithshubham.com" > out/CNAME | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./out | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |