Update node.js.yml #3
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 for the workflow | |
| name: Deploy to GitHub Pages | |
| on: | |
| # Run this workflow when code is pushed to the 'main' branch | |
| push: | |
| branches: [ "main" ] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # Set permissions for the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and the latest queued. | |
| # This prevents race conditions if you push multiple commits quickly. | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| # Build job: builds the Vite project | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| # Use a specific, stable Node.js version for consistency | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build the project | |
| # The VITE_BASE_URL is not strictly needed here because you've already | |
| # set the 'base' in your vite.config.ts, but it's good practice. | |
| run: npm run build | |
| - name: Setup GitHub Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload build artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| # This should match the 'outDir' in your vite.config.ts (default is 'dist') | |
| path: './dist' | |
| # Deploy job: deploys the artifact to GitHub Pages | |
| deploy: | |
| # This job requires the 'build' job to complete successfully | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |