feat: 增加css-loader外链 #66
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: GitHub Actions 部署 vitepress 博客 | |
# 触发时机:表示推送master分支时触发 | |
on: | |
push: | |
branches: | |
- master | |
# 设置时区 | |
env: | |
TZ: Asia/Shanghai | |
# 任务列表 | |
jobs: | |
build-and-deploy: | |
# 运行环境 | |
runs-on: ubuntu-latest | |
# 步骤 | |
steps: | |
# 步骤1:安装Node.js | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
# 步骤2:检出代码 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# 保留 Git 信息 | |
fetch-depth: 0 | |
# 步骤3:安装yarn | |
- name: Install yarn | |
run: npm install -g yarn | |
# 步骤n:删除node_modules,替换或更新包时使用 | |
# - name: Delete node_modules | |
# run: rm -fr node_modules | |
# 步骤4:安装依赖 | |
- name: Install dependencies | |
run: yarn install | |
# 步骤5:删除cache和dist | |
- name: Clean up cache and dist | |
run: | | |
rm -rf Docs/.vitepress/cache | |
rm -rf Docs/.vitepress/dist | |
# 步骤6:构建VitePress | |
- name: Build VitePress | |
run: yarn run build | |
# 步骤7:部署到Github Pages | |
# - name: Deploy to Github Pages | |
# uses: peaceiris/actions-gh-pages@v3 | |
# with: | |
# github_token: ${{ secrets.VITEPRESS_BLOG_TOKEN }} # 自定义的action环境变量 | |
# publish_dir: .vitepress/dist # 指定部署目录 | |
# publish_branch: gh-pages # 指定部署分支 | |
# dotfiles: true # 允许使用.gitignore文件 | |
# 步骤8: scp部署到 vps | |
- name: Deploy to VPS | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} # 服务器地址 | |
username: ${{ secrets.SERVER_USER }} # 服务器用户名 | |
port: ${{ secrets.SERVER_PORT }} # 服务器端口 | |
key: ${{ secrets.SERVER_SSH_KEY }} # 服务器SSH 密钥 | |
# password: ${{ secrets.SERVER_USER_PASSWORD }} # 服务器用户密码 | |
strip_components: 2 # 跳过指定目录 | |
source: 'Docs/.vitepress/dist' # 源目录 | |
target: ${{ secrets.SERVER_TARGET }} # 目标目录 |