SmartParks/.gitea/workflows/dev.yml
bichangxiong 269c105282
Some checks failed
/ build-all (push) Failing after 18s
/ build-and-push-images (ruoyi-auth) (push) Has been skipped
/ build-and-push-images (ruoyi-gateway) (push) Has been skipped
/ build-and-push-images (ruoyi-modules/Property) (push) Has been skipped
/ build-and-push-images (ruoyi-modules/Sis) (push) Has been skipped
/ build-and-push-images (ruoyi-modules/ruoyi-gen) (push) Has been skipped
/ build-and-push-images (ruoyi-modules/ruoyi-job) (push) Has been skipped
/ build-and-push-images (ruoyi-modules/ruoyi-resource) (push) Has been skipped
/ build-and-push-images (ruoyi-modules/ruoyi-system) (push) Has been skipped
/ build-and-push-images (ruoyi-modules/ruoyi-workflow) (push) Has been skipped
/ build-and-push-images (ruoyi-seata-server) (push) Has been skipped
/ build-and-push-images (ruoyi-sentinel-dashboard) (push) Has been skipped
/ build-and-push-images (ruoyi-snailjob-server) (push) Has been skipped
/ build-and-push-images (ruoyi-visual/ruoyi-monitor) (push) Has been skipped
/ build-and-push-images (ruoyi-visual/ruoyi-nacos) (push) Has been skipped
更新 .gitea/workflows/dev.yml
2025-08-14 02:26:30 +08:00

119 lines
4.1 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.

run-name: ${{ gitea.actor }} 构建并推送服务镜像 🚀
on:
push:
branches: [master]
jobs:
# 阶段1通过主POM统一构建所有模块
build-all:
runs-on: ubuntu
steps:
- name: 拉取代码仓库
uses: http://git.missmoc.top/mocheng/checkout@v4
- name: 配置JDK和Maven环境
run: |
# 配置环境变量路径
export JAVA_HOME="/java17/java17"
export MAVEN_HOME="/maven/apache-maven-3.9.11"
# 验证环境是否存在
[ -d "$JAVA_HOME" ] || { echo "错误JDK目录不存在 - $JAVA_HOME"; exit 1; }
[ -d "$MAVEN_HOME" ] || { echo "错误Maven目录不存在 - $MAVEN_HOME"; exit 1; }
# 导出环境变量到工作流
echo "JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
echo "MAVEN_HOME=$MAVEN_HOME" >> $GITHUB_ENV
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
# 输出版本信息验证配置
java -version
mvn -v
- name: 配置Maven仓库阿里云
run: |
# 创建Maven配置目录
mkdir -p ~/.m2
# 写入settings.xml配置
cat > ~/.m2/settings.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<localRepository>${user.home}/.m2/repository</localRepository>
<profiles>
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>aliyun-public</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>aliyun</activeProfile>
</activeProfiles>
</settings>
EOF
- name: 主POM统一打包所有模块
run: |
# 从根目录执行打包命令
mvn clean package -U -DskipTests -f pom.xml
# 验证打包结果
echo "=== 构建产物列表 ==="
find . -name "*.jar" -path "*/target/*"
# 阶段2为每个服务模块构建并推送Docker镜像
build-and-push-images:
needs: build-all
runs-on: ubuntu
strategy:
fail-fast: false # 单个服务失败不影响其他服务构建
matrix:
service:
- ruoyi-auth
- ruoyi-gateway
- ruoyi-modules/Property
- ruoyi-modules/ruoyi-gen
- ruoyi-modules/ruoyi-job
- ruoyi-modules/ruoyi-resource
- ruoyi-modules/ruoyi-system
- ruoyi-modules/ruoyi-workflow
- ruoyi-modules/Sis
- ruoyi-visual/ruoyi-monitor
- ruoyi-visual/ruoyi-nacos
- ruoyi-seata-server
- ruoyi-sentinel-dashboard
- ruoyi-snailjob-server
steps:
- name: 拉取代码仓库
uses: http://git.missmoc.top/mocheng/checkout@v4
- name: 配置Docker Buildx构建环境
uses: http://git.missmoc.top/mocheng/setup-buildx-action@v3
- name: 登录到容器仓库
uses: http://git.missmoc.top/mocheng/login-action@v3
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: 构建并推送服务镜像
uses: http://git.missmoc.top/mocheng/build-push-action@v5
with:
context: . # 构建上下文为项目根目录
file: ./${{ matrix.service }}/Dockerfile # 指定模块的Dockerfile路径
tags: # 镜像标签
${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:${{ github.sha }}
${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:latest
push: true # 推送镜像到仓库
cache-from: type=gha # 使用GitHub Actions缓存
cache-to: type=gha,mode=max # 最大化缓存内容