Merge branch 'master' of github.com:sunven/blog #391
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: Deploy VitePress site to Server | |
on: | |
# 在针对 `main` 分支的推送上运行。如果你 | |
# 使用 `master` 分支作为默认分支,请将其更改为 `master` | |
push: | |
branches: [master] | |
# 允许你从 Actions 选项卡手动运行此工作流程 | |
workflow_dispatch: | |
jobs: | |
docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 9 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
# 选择要使用的 node 版本 | |
node-version: 20 | |
cache: pnpm | |
# 安装依赖 | |
- name: Install dependencies | |
run: pnpm install | |
# 运行构建脚本 | |
- name: Build with VitePress | |
run: pnpm docs:build | |
# 部署到服务器 | |
- name: Deploy to Server | |
uses: easingthemes/ssh-deploy@main | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} | |
ARGS: "-avzr --delete" | |
SOURCE: "docs/.vitepress/dist/" | |
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} | |
REMOTE_USER: "root" | |
TARGET: "/home/blog" |