Create ServerDeploy.yml #1
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: DeployServer | |
# on 表示触发actions的条件 | |
on: | |
push: | |
branches: [main] #main分支在push的时候会触发 | |
pull_request: | |
branches: [main] #main分支在PR的时候会触发 | |
jobs: | |
build: | |
runs-on: ubuntu-latest #nodejs执行的操作系统 | |
steps: | |
- uses: actions/checkout@v3 #拉取你的最新代码 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18.x" # 指定你的node版本 | |
- run: npm install | |
- run: npm run docs:build | |
- name: TranslateFile | |
# uses: wangyucode/sftp-upload-action@24f8bb83383dc39bed201ee5da01475e6c38c568 | |
uses: wangyucode/sftp-upload-action@v1.1 | |
with: | |
host: ${{ secrets.SERVER_IP }} #你的nginx服务器公网ip | |
port: ${{ secrets.SERVER_PORT }} #你的nginx服务器ssh端口 | |
username: ${{ secrets.USERNAME }} #你的nginx服务器用户名 | |
password: ${{ secrets.PASSWORD }} #你的nginx服务器密码 | |
localDir: "dist" #你vue项目build好的文件的路径,每次服务器上会自动删除对应的文件夹后重新覆盖 | |
remoteDir: ${{ secrets.SERVER_DESTINATION }} #你要把你build好的文件夹放到nginx服务器上的什么位置,一般都是nginx配置的站点路径 |