Files
light/.gitea/workflows/deploy.yml
Doubleyin 2641c2da25
Some checks failed
构建并部署 Spring Boot 应用 / build-and-deploy (push) Has been cancelled
添加 CI/CD 自动化部署流程
2025-09-26 00:51:23 +08:00

42 lines
1.3 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: 构建并部署 Spring Boot 应用
on: [push] # 当有任何代码推送到仓库时触发此工作流
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 步骤1获取最新的代码
- name: 检出代码
uses: actions/checkout@v4
# 步骤2设置 Java 环境
- name: 设置 JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# 步骤3使用 Maven 打包应用
- name: 使用 Maven 打包
run: mvn clean package -DskipTests
# 步骤4构建 Docker 镜像
- name: 构建 Docker 镜像
run: |
docker build -t light-delivery-app:latest .
# 步骤5部署到应用服务器
- name: 部署到服务器
run: |
# 使用 SSH 连接到您的应用服务器并执行部署命令
ssh root@115.190.121.151 '
docker stop light-delivery-container || true
docker rm light-delivery-container || true
docker run -d \
--name light-delivery-container \
-p 443:443 \
-p 80:80 \
-v /etc/ssl/certs:/etc/ssl/certs \
-e KEY_STORE_PASSWORD="$(cat /etc/ssl/certs/keyStorePass.txt)" \
light-delivery-app:latest
'