|
1 | | -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node |
2 | | -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs |
3 | | - |
4 | | -name: Node.js CI |
| 1 | +# Name for the workflow |
| 2 | +name: Deploy to GitHub Pages |
5 | 3 |
|
6 | 4 | on: |
| 5 | + # Run this workflow when code is pushed to the 'main' branch |
7 | 6 | push: |
8 | 7 | branches: [ "main" ] |
9 | | - pull_request: |
10 | | - branches: [ "main" ] |
| 8 | + # Allows you to run this workflow manually from the Actions tab |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +# Set permissions for the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and the latest queued. |
| 18 | +# This prevents race conditions if you push multiple commits quickly. |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: true |
11 | 22 |
|
12 | 23 | jobs: |
| 24 | + # Build job: builds the Vite project |
13 | 25 | build: |
14 | | - |
15 | 26 | runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + # Use a specific, stable Node.js version for consistency |
| 35 | + node-version: 20 |
| 36 | + cache: 'npm' |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: npm ci |
16 | 40 |
|
17 | | - strategy: |
18 | | - matrix: |
19 | | - node-version: [18.x, 20.x, 22.x] |
20 | | - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 41 | + - name: Build the project |
| 42 | + # The VITE_BASE_URL is not strictly needed here because you've already |
| 43 | + # set the 'base' in your vite.config.ts, but it's good practice. |
| 44 | + run: npm run build |
| 45 | + |
| 46 | + - name: Setup GitHub Pages |
| 47 | + uses: actions/configure-pages@v5 |
21 | 48 |
|
| 49 | + - name: Upload build artifact |
| 50 | + uses: actions/upload-pages-artifact@v3 |
| 51 | + with: |
| 52 | + # This should match the 'outDir' in your vite.config.ts (default is 'dist') |
| 53 | + path: './dist' |
| 54 | + |
| 55 | + # Deploy job: deploys the artifact to GitHub Pages |
| 56 | + deploy: |
| 57 | + # This job requires the 'build' job to complete successfully |
| 58 | + needs: build |
| 59 | + runs-on: ubuntu-latest |
| 60 | + environment: |
| 61 | + name: github-pages |
| 62 | + url: ${{ steps.deployment.outputs.page_url }} |
22 | 63 | steps: |
23 | | - - uses: actions/checkout@v4 |
24 | | - - name: Use Node.js ${{ matrix.node-version }} |
25 | | - uses: actions/setup-node@v4 |
26 | | - with: |
27 | | - node-version: ${{ matrix.node-version }} |
28 | | - cache: 'npm' |
29 | | - - run: npm ci |
30 | | - - run: npm run build --if-present |
31 | | - - run: npm test |
| 64 | + - name: Deploy to GitHub Pages |
| 65 | + id: deployment |
| 66 | + uses: actions/deploy-pages@v4 |
0 commit comments