Skip to content

feat: 更换打包方式 #52

feat: 更换打包方式

feat: 更换打包方式 #52

Workflow file for this run

name: 发布镜像
on:
push:
branches: [ "master" ] # 触发条件:推送到 master 分支
jobs:
publish_dev_code:
runs-on: ubuntu-latest
# needs: back_java # 确保在备份代码作业成功后才执行
steps:
- name: 打印信息 🎉
run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- name: 打印操作系统信息 🐧
run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- name: 打印分支和仓库信息 🔎
run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: 检查仓库代码 👁︎
uses: actions/checkout@v4
- name: 打印仓库文件列表 📦
run: ls ${{ github.workspace }}
- name: 查看 zip 文件 📦
run: ls
- name: 删除之前的文件
uses: cross-the-world/ssh-scp-ssh-pipelines@latest
env:
LASTSSH: "Doing something after copying"
with:
host: ${{ secrets.DEV_SERVER_HOST }}
user: ${{ secrets.DEV_SERVER_USER }}
pass: ${{ secrets.DEV_SERVER_PASSWORD }}
last_ssh: |
cd /opt/app/test
rm -rf * # 删除目录下所有文件和子目录
- name: 打包代码成 ZIP 文件 📦
id: deploy
run: |
zip -r publish.zip . -x "*.git*"
echo "::set-output name=zip-path::publish.zip"
- name: 推送到测试服务器备份 zip 文件夹
uses: cross-the-world/ssh-scp-ssh-pipelines@latest
env:
LASTSSH: "Doing something after copying"
with:
host: ${{ secrets.DEV_SERVER_HOST }}
user: ${{ secrets.DEV_SERVER_USER }}
pass: ${{ secrets.DEV_SERVER_PASSWORD }}
scp: |
./publish.zip => /opt/app/zip
last_ssh: |
ls
- name: 推送到测试服务器备份 zip 文件夹
uses: cross-the-world/ssh-scp-ssh-pipelines@latest
env:
LASTSSH: "Doing something after copying"
with:
host: ${{ secrets.DEV_SERVER_HOST }}
user: ${{ secrets.DEV_SERVER_USER }}
pass: ${{ secrets.DEV_SERVER_PASSWORD }}
scp: |
./publish.zip => /opt/app/test
last_ssh: |
ls
- name: 解压文件publish.zip
uses: easingthemes/[email protected]
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_USER: ${{ secrets.DEV_SERVER_USER }}
REMOTE_HOST: ${{ secrets.DEV_SERVER_HOST }}
REMOTE_PORT: 22
SCRIPT_AFTER: |
cd /opt/app/test
unzip publish.zip
- name: 打包 maven
uses: cross-the-world/ssh-scp-ssh-pipelines@latest
env:
LASTSSH: "Doing something after copying"
with:
host: ${{ secrets.DEV_SERVER_HOST }}
user: ${{ secrets.DEV_SERVER_USER }}
pass: ${{ secrets.DEV_SERVER_PASSWORD }}
last_ssh: |
cd /opt/app/test
mvn clean install
# - name: mvn 打包
# uses: easingthemes/[email protected]
# with:
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# REMOTE_USER: ${{ secrets.DEV_SERVER_USER }}
# REMOTE_HOST: ${{ secrets.DEV_SERVER_HOST }}
# REMOTE_PORT: 22
# SCRIPT_AFTER: |
# cd /opt/app/test
# mvn clean install
- name: 运行 env 镜像
uses: easingthemes/[email protected]
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_USER: ${{ secrets.DEV_SERVER_USER }}
REMOTE_HOST: ${{ secrets.DEV_SERVER_HOST }}
REMOTE_PORT: 22
SCRIPT_AFTER: |
cd /opt/app/test
docker-compose -f docker-compose.env.yml up -d
- name: 运行 env 镜像
uses: easingthemes/[email protected]
with:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
REMOTE_USER: ${{ secrets.DEV_SERVER_USER }}
REMOTE_HOST: ${{ secrets.DEV_SERVER_HOST }}
REMOTE_PORT: 22
SCRIPT_AFTER: |
cd /opt/app/test
docker-compose -f docker-compose.service.yml up -d
- name: 打印作业状态 🍏
run: echo "🍏 This job's status is ${{ job.status }}."