Update template.md #77
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
# 一个workflow,名为deploy to tengxunyun | |
name: deploy-to-cvm | |
on: # 此CI/CD触发时的事件 | |
push: # 在代码提交时自动触发 | |
branches: | |
- master | |
# 一个 CI/CD 的工作流有许多 jobs 组成,比如最典型的 job 是 lint,test,build。 | |
jobs: | |
build: # 构建job | |
runs-on: ubuntu-latest # 跑workflow的服务器系统 | |
steps: # job的一系列动作 | |
# 切换分支获取源码 | |
- name: Checkout # step的名称,将会在 github action 的控制台中显示 | |
# 选择一个action,可以理解为若干 steps.run,有利于代码复用 | |
uses: actions/checkout@master | |
with: | |
ssh-key: ${{ secrets.SSH }} | |
submodules: true | |
# 安装使用 node:12 | |
- name: use Node.js 12 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 12 | |
# 运行命令,npm install && npm run build | |
- name: npm install and build | |
run: | | |
npm install | |
rm -rf ./blog/onlygithub | |
npm run build | |
env: | |
CI: true | |
# 部署到腾讯云服务器 | |
- name: Deploy to Server | |
uses: easingthemes/[email protected] | |
env: | |
# 本地.ssh文件下的私钥id_rsa,存在secrets的TOKEN中 | |
SSH_PRIVATE_KEY: ${{ secrets.SSH }} | |
# 复制操作的参数。"-avzr --delete"意味部署时清空服务器目标目录下的文件 | |
ARGS: "-avzr --delete" | |
# 源目录,相对于$GITHUB_WORKSPACE根目录的路径 | |
SOURCE: "blog/.vuepress/dist/" | |
# 服务器域名 | |
REMOTE_HOST: "kimyang.cn" | |
# 腾讯云默认用户名为root | |
REMOTE_USER: "kim" | |
# 目标目录 | |
TARGET: "/srv/kim-blog/" |