Files
light/.gitea/workflows/deploy.yml
Doubleyin 9101237d9a
Some checks failed
构建并部署 Spring Boot 应用 / build-and-deploy (push) Failing after 1m30s
修复:禁用Node.js缓存
2025-09-26 02:02:28 +08:00

58 lines
1.7 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-24.04
steps:
# 1. 设置 Node.js禁用缓存
- name: 为 Gitea Actions 设置 Node.js 环境
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'none' # 关键修改:禁用缓存
# 2. 检出代码
- name: 检出代码
uses: actions/checkout@v4
# 3. 设置 Java 环境
- name: 设置 JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# 4. 使用 Maven 打包
- name: 使用 Maven 打包
run: mvn clean package -DskipTests
# 5. 构建 Docker 镜像
- name: 构建 Docker 镜像
run: |
docker build -t light-delivery-app:latest .
# 6. 部署到服务器
- name: 部署到服务器
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
# 配置SSH环境
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
echo -e "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh/config
# 部署到服务器
ssh -i ~/.ssh/deploy_key root@115.190.121.151 '
echo "🚀 开始部署应用..."
docker rm -f 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
echo "✅ 部署完成!"
'