Skip to content

Commit

Permalink
fix: update the ci to build docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenngoclongdev authored Oct 25, 2024
1 parent afa8f17 commit 21c7bee
Showing 1 changed file with 43 additions and 32 deletions.
75 changes: 43 additions & 32 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,70 @@
name: Documentation

on:
# trigger deployment on push to master branch when changes to docs/**
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
paths:
- "docs/**"
branches:
- main
# trigger deployment manually

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
deploy:
# Build job
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs/

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
with:
# fetch all commits to get last updated time or other git log info
fetch-depth: 0
fetch-depth: 0 # Not needed if lastUpdated is not enabled

- name: Setup Node.js
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Cache dependencies
uses: actions/cache@v4
id: npm-cache
with:
path: |
**/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
node-version: 20
cache: npm

- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm install
run: npm ci

- name: Build VitePress site
- name: Build with VitePress
run: npm run 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
uses: crazy-max/ghaction-github-pages@v4
with:
# deploy to gh-pages branch
target_branch: gh-pages
# deploy the default output dir of VitePress
build_dir: docs/.vitepress/dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit 21c7bee

Please sign in to comment.