Update github-action.yml #58
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 blog | |
# 监听 master 分支上的 push 事件 | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
# 构建环境使用 ubuntu | |
runs-on: ubuntu-latest | |
steps: | |
# 官方action, 将代码拉取到虚拟机 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
# 安装node.js | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16.15.1" | |
# 下载依赖、打包项目 | |
- name: Install and Build | |
run: | | |
yarn install | |
yarn docs:build | |
# 编译后的文件上传新分支 | |
- name: Deploy | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
BRANCH: blog | |
FOLDER: src/.vuepress/dist | |
deploy-server: | |
runs-on: ubuntu-latest | |
needs: build-and-deploy | |
steps: | |
- name: Checkout Blog | |
uses: actions/checkout@v3 | |
with: | |
ref: blog | |
fetch-depth: 0 | |
# 部署到服务器 | |
- name: Upload to Deploy Server | |
uses: appleboy/scp-action@master | |
with: | |
# 服务器域名 | |
host: ${{ secrets.SERVER_HOST }} | |
# 服务器用户名 | |
username: ${{ secrets.SERVER_USERNAME }} | |
# 服务器密码 | |
password: ${{ secrets.SERVER_PASSWORD }} | |
# 指定上传的文件目录(项目配置的打包目录名称) | |
source: './*' | |
# 指定上传服务器目录 | |
target: '/www/wwwroot/yaien' | |
# 解压时覆盖现有文件 | |
overwrite: true |