Skip to content

Commit

Permalink
ci: 简化 github 部署配置
Browse files Browse the repository at this point in the history
  • Loading branch information
maomao1996 committed Jan 29, 2024
1 parent 72e09a3 commit 26232ce
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
- 'docs/**'
- 'package.json'

# 设置权限
permissions:
contents: write

# 设置上海时区
env:
TZ: Asia/Shanghai
Expand All @@ -25,9 +29,9 @@ jobs:
steps:
# 拉取代码
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0

# 安装 pnpm
- name: Install pnpm
Expand All @@ -44,15 +48,15 @@ jobs:

# 打包静态文件
- name: Build
run: pnpm install && pnpm run build:github
env:
APP_BASE_PATH: /${{ github.repository }}
run: pnpm install && pnpm run build

# 部署
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
uses: JamesIves/github-pages-deploy-action@v4
with:
# GitHub 密钥
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# GitHub Pages 读取的分支
BRANCH: gh-pages
branch: gh-pages
# 静态文件所在目录
FOLDER: dist
folder: dist
5 changes: 4 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { basename } from 'node:path'
import { defineConfig } from 'vitepress'
import MarkdownPreview from 'vite-plugin-markdown-preview'

import { head, nav, sidebar } from './configs'

const APP_BASE_PATH = basename(process.env.GITHUB_REPOSITORY || '')

export default defineConfig({
outDir: '../dist',
base: process.env.APP_BASE_PATH || '/',
base: APP_BASE_PATH ? `/${APP_BASE_PATH}/` : '/',

lang: 'zh-CN',
title: '茂茂物语',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"scripts": {
"dev": "vitepress dev docs --port=8732",
"build": "vitepress build docs",
"build:github": "cross-env APP_BASE_PATH=/vitepress-nav-template/ vitepress build docs",
"prepare": "husky install",
"format": "prettier --write ."
},
Expand Down

1 comment on commit 26232ce

@vercel
Copy link

@vercel vercel bot commented on 26232ce Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.