updates #6
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: deployToEcs | |
#触发工作流的事件 | |
on: | |
push: | |
branches: [ "master" ] | |
jobs: | |
build-and-deploy: | |
#运行在Ubuntu最新版的镜像上运行 | |
runs-on: ubuntu-latest | |
steps: | |
#检查并拉取代码 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
#设置环境为nodejs 18 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
- run: npm install --frozen-lockfile | |
#安装模块并打包项目 | |
- name: Build Project | |
run: | |
npm run docs:build | |
#将文件上传至云服务器 | |
- name: ssh-scp-deploy | |
uses: marcodallasanta/[email protected] | |
with: | |
#本地打包后的文件目录 | |
local: docs/.vitepress/dist | |
#上传至远程服务器的目标目录 | |
remote: /usr/local/nginx/html | |
#远程服务器的地址 | |
host: ${{ secrets.REMOTE_HOST }} | |
#远程服务器的用户名 | |
user: ${{ secrets.REMOTE_USERNAME }} | |
#远程服务器的密钥(与密码二者选其一) | |
key: ${{ secrets.PRIVATE_KEY }} | |
#上传后执行的脚本 | |
post_upload: nginx -s reload |