|
| 1 | +# Sample workflow for building and deploying a VitePress site to GitHub Pages |
| 2 | +# |
| 3 | +name: Deploy VitePress site to Pages |
| 4 | + |
| 5 | +on: |
| 6 | + # Runs on pushes targeting the `main` branch. Change this to `master` if you're |
| 7 | + # using the `master` branch as the default branch. |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + |
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + working-directory: src |
| 17 | + |
| 18 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + pages: write |
| 22 | + id-token: write |
| 23 | + |
| 24 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 25 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 26 | +concurrency: |
| 27 | + group: pages |
| 28 | + cancel-in-progress: false |
| 29 | + |
| 30 | +jobs: |
| 31 | + # Build job |
| 32 | + build: |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Checkout |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + fetch-depth: 0 # Not needed if lastUpdated is not enabled |
| 39 | + # - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm |
| 40 | + # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun |
| 41 | + - name: Setup Node |
| 42 | + uses: actions/setup-node@v4 |
| 43 | + with: |
| 44 | + node-version-file: ./src/.nvmrc |
| 45 | + cache: "npm" |
| 46 | + cache-dependency-path: "./src/package-lock.json" |
| 47 | + |
| 48 | + - name: Setup Pages |
| 49 | + uses: actions/configure-pages@v4 |
| 50 | + |
| 51 | + - name: Install dependencies |
| 52 | + run: npm ci # or pnpm install / yarn install / bun install |
| 53 | + |
| 54 | + - name: Build with VitePress |
| 55 | + run: | |
| 56 | + npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build |
| 57 | + touch docs/.vitepress/dist/.nojekyll |
| 58 | +
|
| 59 | + - name: Upload artifact |
| 60 | + uses: actions/upload-pages-artifact@v3 |
| 61 | + with: |
| 62 | + path: ./src/docs/.vitepress/dist |
| 63 | + |
| 64 | + # Deployment job |
| 65 | + deploy: |
| 66 | + environment: |
| 67 | + name: github-pages |
| 68 | + url: ${{ steps.deployment.outputs.page_url }} |
| 69 | + needs: build |
| 70 | + runs-on: ubuntu-latest |
| 71 | + name: Deploy |
| 72 | + steps: |
| 73 | + - name: Deploy to GitHub Pages |
| 74 | + id: deployment |
| 75 | + uses: actions/deploy-pages@v4 |
0 commit comments