|
1 |
| -name: Build and Deploy Docs to GitHub Pages |
| 1 | +# Sample workflow for building and deploying a VitePress site to GitHub Pages |
| 2 | +# |
| 3 | +name: Deploy VitePress site to Pages |
2 | 4 |
|
3 | 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. |
4 | 8 | push:
|
5 |
| - branches: |
6 |
| - - master |
7 |
| - - dev |
| 9 | + branches: [main,dev] |
8 | 10 |
|
| 11 | + # Allows you to run this workflow manually from the Actions tab |
| 12 | + workflow_dispatch: |
9 | 13 |
|
| 14 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + pages: write |
| 18 | + id-token: write |
| 19 | + |
| 20 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 21 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 22 | +concurrency: |
| 23 | + group: pages |
| 24 | + cancel-in-progress: false |
10 | 25 |
|
11 | 26 | jobs:
|
| 27 | + # Build job |
12 | 28 | build:
|
13 | 29 | runs-on: ubuntu-latest
|
14 |
| - |
15 | 30 | steps:
|
16 |
| - - name: Checkout repository |
17 |
| - uses: actions/checkout@v3 |
18 |
| - |
19 |
| - - name: Set up Node.js |
20 |
| - uses: actions/setup-node@v3 |
21 |
| - with: |
22 |
| - node-version: '20' |
23 |
| - |
24 |
| - - name: Cache Node.js dependencies |
25 |
| - uses: actions/cache@v3 |
26 |
| - with: |
27 |
| - path: ~/.npm |
28 |
| - key: npm-cache-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} |
29 |
| - restore-keys: | |
30 |
| - npm-cache-${{ runner.os }}- |
31 |
| - - name: Install dependencies |
32 |
| - run: npm install |
33 |
| - |
34 |
| - - name: Build docs |
35 |
| - run: npm run docs:build:master |
36 |
| - |
37 |
| - - name: Upload production-ready files |
38 |
| - uses: actions/upload-artifact@v4 |
39 |
| - with: |
40 |
| - name: dist-files |
41 |
| - path: ./docs/.vitepress/dist |
42 |
| - - name: List output directory |
43 |
| - run: ls -la ./docs/.vitepress/dist |
| 31 | + - name: Checkout |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + fetch-depth: 0 # Not needed if lastUpdated is not enabled |
| 35 | + # - uses: pnpm/action-setup@v3 # Uncomment this block if you're using pnpm |
| 36 | + # with: |
| 37 | + # version: 9 # Not needed if you've set "packageManager" in package.json |
| 38 | + # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun |
| 39 | + - name: Setup Node |
| 40 | + uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version: 20 |
| 43 | + cache: npm # or pnpm / yarn |
| 44 | + - name: Setup Pages |
| 45 | + uses: actions/configure-pages@v4 |
| 46 | + - name: Install dependencies |
| 47 | + run: npm ci # or pnpm install / yarn install / bun install |
| 48 | + - name: Build with VitePress |
| 49 | + run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build |
| 50 | + - name: Upload artifact |
| 51 | + uses: actions/upload-pages-artifact@v3 |
| 52 | + with: |
| 53 | + path: docs/.vitepress/dist |
44 | 54 |
|
| 55 | + # Deployment job |
45 | 56 | deploy:
|
46 | 57 | environment:
|
47 | 58 | name: github-pages
|
48 | 59 | url: ${{ steps.deployment.outputs.page_url }}
|
49 |
| - permissions: write-all |
50 |
| - #pages: write # To deploy to GitHub Pages |
51 |
| - #id-token: write # Required for Pages deployment |
52 | 60 | needs: build
|
53 | 61 | runs-on: ubuntu-latest
|
| 62 | + name: Deploy |
54 | 63 | steps:
|
55 |
| - - name: Download production-ready files |
56 |
| - uses: actions/download-artifact@v4 |
57 |
| - with: |
58 |
| - name: dist-files |
59 |
| - |
60 |
| - - name: Deploy to GitHub Pages |
61 |
| - uses: actions/deploy-pages@v4 |
62 |
| - |
63 |
| - with: |
64 |
| - artifact: dist-files |
| 64 | + - name: Deploy to GitHub Pages |
| 65 | + id: deployment |
| 66 | + uses: actions/deploy-pages@v4 |
0 commit comments