Deployment docs #21
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: Build & Deploy VitePress Site | |
| # Trigger the workflow on push to the dev branch | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| # Add permissions to allow GitHub token to push to the repository | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source code from dev branch | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: dev | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build VitePress site | |
| run: npm run docs:build | |
| # Ensure your package.json has a script like: | |
| # "docs:build": "vitepress build docs" | |
| - name: Deploy built site to main branch | |
| working-directory: docs/.vitepress/dist | |
| run: | | |
| git init | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| git commit -m "Deploy VitePress site" | |
| git branch -M main | |
| git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git | |
| git push -f origin main |