Update build.yml #29
Workflow file for this run
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: Build and Deploy | |
on: | |
push: | |
#branches: | |
# - main | |
# - dev | |
tags: | |
- '*' # 监听所有的tag push事件 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# 检出当前的代码仓库 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# 安装 sshpass 工具,用于处理 SCP 密码认证 | |
- name: Install sshpass | |
run: sudo apt-get install -y sshpass | |
# 设置 Node.js 版本 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' # 设置 Node.js 版本,你可以根据你的项目需要调整 | |
# 安装依赖 | |
- name: Install dependencies | |
run: | | |
cd front_end | |
npm install | |
# 运行构建命令 | |
- name: Build project 1 | |
run: | | |
cd front_end | |
npm run build:openms | |
cd dist | |
# 打包完后,下载录像播放器 | |
wget "https://github.com/eee555/flop-player/releases/download/v1.1/dist.zip" | |
unzip dist.zip | |
rm dist.zip | |
mv dist flop | |
# 从gitee下载文章静态资源 | |
mkdir article | |
cd article | |
git clone https://gitee.com/ee55/saolei_website_article.git | |
cp -r saolei_website_article/* ./ | |
ls | |
rm -rf .git | |
rm LICENSE | |
rm -r saolei_website_article | |
# 使用SCP或其他方式上传文件到远程服务器 | |
- name: Upload files to server 1 | |
env: | |
SERVER_HOST: ${{ secrets.SERVER_HOST }} # 服务器地址 | |
SERVER_USER: ${{ secrets.SERVER_USER }} # 服务器用户名 | |
SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }} # 服务器密码 | |
REMOTE_PATH: ${{ secrets.REMOTE_PATH }} # 远程路径,不保密 | |
run: | | |
echo Uploading build files to server... | |
cd front_end | |
sshpass -p "${SERVER_PASSWORD}" scp -o StrictHostKeyChecking=no -r dist ${{ env.SERVER_USER }}@${{ env.SERVER_HOST }}:/root/github/saolei_website/back_end/saolei | |
# # 运行构建命令 | |
# - name: Build project 2 | |
# run: | | |
# cd front_end | |
# npm run build:openms | |
# cd dist | |
# # 打包完后,下载录像播放器 | |
# wget "https://github.com/eee555/flop-player/releases/download/v1.1/dist.zip" | |
# unzip dist.zip | |
# rm dist.zip | |
# mv dist flop | |
# # 从gitee下载文章静态资源 | |
# mkdir article | |
# cd article | |
# git clone https://gitee.com/ee55/saolei_website_article.git | |
# cp -r saolei_website_article/* ./ | |
# ls | |
# rm -rf .git | |
# rm LICENSE | |
# rm -r saolei_website_article | |
# # 使用SCP或其他方式上传文件到远程服务器 | |
# - name: Upload files to server 2 | |
# env: | |
# SERVER_HOST: ${{ secrets.SERVER_HOST }} # 服务器地址 | |
# SERVER_USER: ${{ secrets.SERVER_USER }} # 服务器用户名 | |
# SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }} # 服务器密码 | |
# REMOTE_PATH: ${{ secrets.REMOTE_PATH }} # 远程路径,不保密 | |
# run: | | |
# echo Uploading build files to server... | |
# cd front_end | |
# sshpass -p "${SERVER_PASSWORD}" scp -o StrictHostKeyChecking=no -r dist ${{ env.SERVER_USER }}@${{ env.SERVER_HOST }}:/root/saolei/static/openms | |