-
Notifications
You must be signed in to change notification settings - Fork 6
72 lines (61 loc) · 2.02 KB
/
vitepress-release.yml
File metadata and controls
72 lines (61 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: vitepress-release
on:
workflow_dispatch:
inputs:
version:
description: Version to deploy (e.g., v1.7.0)
required: true
push:
tags:
- 'v*'
jobs:
deploy:
name: Deploy release docs
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Determine version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
run: npm ci
- name: Build VitePress
run: npm run docs:build
env:
VITEPRESS_BASE: /${{ steps.version.outputs.version }}/
- name: Deploy to gh-pages
run: |
VERSION=${{ steps.version.outputs.version }}
git config user.name "GitHub Actions Bot"
git config user.email "actions-bot@github.com"
# Clone gh-pages branch
git clone --branch gh-pages --single-branch \
https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git gh-pages-deploy
# Remove old version if exists, copy new version
rm -rf "gh-pages-deploy/$VERSION"
cp -r docs/.vitepress/dist "gh-pages-deploy/$VERSION"
# Update latest symlink (copy instead of symlink for GitHub Pages)
rm -rf gh-pages-deploy/latest
cp -r "gh-pages-deploy/$VERSION" gh-pages-deploy/latest
# Update versions.json
cd gh-pages-deploy
node ../scripts/update-versions.js "$VERSION" vitepress latest
# Commit and push
git add -A
git commit -m "Deploy $VERSION docs"
git push