Documentation #1
This file contains 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: Documentation | |
on: | |
# trigger deployment on push to master branch when changes to docs/** | |
push: | |
paths: | |
- "docs/**" | |
branches: | |
- main | |
# trigger deployment manually | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: docs/ | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# fetch all commits to get last updated time or other git log info | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20" | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
id: npm-cache | |
with: | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
- name: Install dependencies | |
if: steps.npm-cache.outputs.cache-hit != 'true' | |
run: npm install | |
- name: Build VitePress site | |
run: npm run docs:build | |
- name: Bundle CNAME with site dist | |
run: cp CNAME .vitepress/dist | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: docs/.vitepress/dist | |
# Deployment job | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
needs: build | |
runs-on: ubuntu-latest | |
name: Deploy | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |