|
| 1 | +name: Deploy VitePress Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'docs/**' |
| 8 | + - '.github/workflows/deploy-docs.yml' |
| 9 | + workflow_dispatch: # Allow manual triggers |
| 10 | + |
| 11 | +# Sets permissions for GitHub Pages deployment |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Prevent concurrent deployments |
| 18 | +concurrency: |
| 19 | + group: pages |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 # For lastUpdated feature |
| 30 | + |
| 31 | + - name: Retrieve Node.js version |
| 32 | + id: node-version |
| 33 | + run: | |
| 34 | + if [ -f .tool-versions ]; then |
| 35 | + echo "node-version=$(grep '^nodejs ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT |
| 36 | + else |
| 37 | + echo "node-version=20" >> $GITHUB_OUTPUT |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Setup Node.js |
| 41 | + uses: actions/setup-node@v4 |
| 42 | + with: |
| 43 | + node-version: ${{ steps.node-version.outputs.node-version }} |
| 44 | + cache: 'npm' |
| 45 | + cache-dependency-path: docs/package-lock.json |
| 46 | + |
| 47 | + - name: Setup Pages |
| 48 | + uses: actions/configure-pages@v4 |
| 49 | + |
| 50 | + - name: Install dependencies |
| 51 | + working-directory: docs |
| 52 | + run: npm ci |
| 53 | + |
| 54 | + - name: Build with VitePress |
| 55 | + working-directory: docs |
| 56 | + run: npm run build |
| 57 | + |
| 58 | + - name: Upload artifact |
| 59 | + uses: actions/upload-pages-artifact@v3 |
| 60 | + with: |
| 61 | + path: docs/.vitepress/dist |
| 62 | + |
| 63 | + deploy: |
| 64 | + environment: |
| 65 | + name: github-pages |
| 66 | + url: ${{ steps.deployment.outputs.page_url }} |
| 67 | + needs: build |
| 68 | + runs-on: ubuntu-latest |
| 69 | + steps: |
| 70 | + - name: Deploy to GitHub Pages |
| 71 | + id: deployment |
| 72 | + uses: actions/deploy-pages@v4 |
0 commit comments