Deploy to GitHub Pages #1014
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: | |
| # Trigger on interview-questions repo update | |
| repository_dispatch: | |
| types: [interview-questions-updated] | |
| # 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 }} | |
| # Interview Questions Repository Configuration | |
| NEXT_PUBLIC_INTERVIEW_REPO_OWNER: arcadep0156 | |
| NEXT_PUBLIC_INTERVIEW_REPO_NAME: interview-questions | |
| NEXT_PUBLIC_INTERVIEW_REPO_BRANCH: main | |
| # 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 |