更新 .gitea/workflows/dev.yml
Some checks failed
/ build-parent-pom (push) Failing after 18s
/ build-common-modules (push) Has been skipped
/ build-and-push-services (ruoyi-auth) (push) Has been skipped
/ build-and-push-services (ruoyi-gateway) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/Property) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/Sis) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-gen) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-job) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-resource) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-system) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-workflow) (push) Has been skipped
/ build-and-push-services (ruoyi-seata-server) (push) Has been skipped
/ build-and-push-services (ruoyi-sentinel-dashboard) (push) Has been skipped
/ build-and-push-services (ruoyi-snailjob-server) (push) Has been skipped
/ build-and-push-services (ruoyi-visual/ruoyi-monitor) (push) Has been skipped
/ build-and-push-services (ruoyi-visual/ruoyi-nacos) (push) Has been skipped
Some checks failed
/ build-parent-pom (push) Failing after 18s
/ build-common-modules (push) Has been skipped
/ build-and-push-services (ruoyi-auth) (push) Has been skipped
/ build-and-push-services (ruoyi-gateway) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/Property) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/Sis) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-gen) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-job) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-resource) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-system) (push) Has been skipped
/ build-and-push-services (ruoyi-modules/ruoyi-workflow) (push) Has been skipped
/ build-and-push-services (ruoyi-seata-server) (push) Has been skipped
/ build-and-push-services (ruoyi-sentinel-dashboard) (push) Has been skipped
/ build-and-push-services (ruoyi-snailjob-server) (push) Has been skipped
/ build-and-push-services (ruoyi-visual/ruoyi-monitor) (push) Has been skipped
/ build-and-push-services (ruoyi-visual/ruoyi-nacos) (push) Has been skipped
This commit is contained in:
parent
507c2e4d8d
commit
f2d66263af
@ -1,93 +1,111 @@
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
run-name: ${{ gitea.actor }} is building with parent POM first 🚀
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master # 监听master分支
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-common-modules:
|
||||
# 步骤1:构建项目主POM(父模块),安装到本地仓库
|
||||
build-parent-pom:
|
||||
runs-on: ubuntu
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||||
|
||||
- name: Set up environment (JDK + Maven)
|
||||
run: |
|
||||
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
|
||||
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
|
||||
# 配置Maven
|
||||
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
||||
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
|
||||
echo "Java version:"
|
||||
java -version
|
||||
echo "Maven version:"
|
||||
/maven/apache-maven-3.9.11/bin/mvn -v
|
||||
echo "JAVA_HOME: $JAVA_HOME"
|
||||
echo "MAVEN_HOME: $MAVEN_HOME"
|
||||
$MAVEN_HOME/bin/mvn -v
|
||||
|
||||
- name: Configure Maven settings
|
||||
- name: Configure Maven settings (本地优先 + 官方仓库)
|
||||
run: |
|
||||
# 创建Maven配置文件,添加必要仓库
|
||||
mkdir -p ~/.m2
|
||||
cat > ~/.m2/settings.xml << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<settings>
|
||||
<mirrors>
|
||||
<!-- Maven中央仓库 -->
|
||||
<mirror>
|
||||
<id>central</id>
|
||||
<url>https://repo1.maven.org/maven2</url>
|
||||
<mirrorOf>central</mirrorOf>
|
||||
</mirror>
|
||||
<!-- Dromara官方仓库 -->
|
||||
<mirror>
|
||||
<id>dromara-repo</id>
|
||||
<localRepository>${user.home}/.m2/repository</localRepository>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local-first</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>local-repo</id>
|
||||
<url>file://${user.home}/.m2/repository</url>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
<snapshots><enabled>true</enabled></snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dromara-releases</id>
|
||||
<url>https://maven.dromara.org/repository/releases/</url>
|
||||
<mirrorOf>dromara</mirrorOf>
|
||||
</mirror>
|
||||
<!-- 内部仓库(如有请取消注释并修改地址) -->
|
||||
<!--
|
||||
<mirror>
|
||||
<id>internal-repo</id>
|
||||
<url>http://your-internal-repo-url/maven-releases/</url>
|
||||
<mirrorOf>internal</mirrorOf>
|
||||
</mirror>
|
||||
-->
|
||||
</mirrors>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
|
||||
<releases><enabled>false</enabled></releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>local-first</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
||||
EOF
|
||||
|
||||
- name: Build and install parent POM (主POM)
|
||||
run: |
|
||||
# 主POM路径(通常在项目根目录)
|
||||
MAIN_POM_PATH="./pom.xml"
|
||||
if [ ! -f "$MAIN_POM_PATH" ]; then
|
||||
echo "Error: 主POM文件 $MAIN_POM_PATH 不存在"
|
||||
exit 1
|
||||
fi
|
||||
# -N 表示只构建当前模块(不构建子模块),仅安装父POM到本地仓库
|
||||
$MAVEN_HOME/bin/mvn clean install -N -U -DskipTests -f $MAIN_POM_PATH
|
||||
# 验证父POM是否安装成功
|
||||
ls ~/.m2/repository/org/dromara/ruoyi-cloud-plus/${{ github.sha }}/ # 替换为实际groupId/artifactId
|
||||
|
||||
# 步骤2:构建通用模块(依赖主POM)
|
||||
build-common-modules:
|
||||
needs: build-parent-pom
|
||||
runs-on: ubuntu
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||||
|
||||
- name: Set up environment
|
||||
run: |
|
||||
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
|
||||
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
|
||||
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
||||
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Build and install common modules
|
||||
run: |
|
||||
# 构建并安装项目通用模块(根据实际项目结构调整)
|
||||
# 核心通用模块
|
||||
if [ -f "./ruoyi-common/pom.xml" ]; then
|
||||
/maven/apache-maven-3.9.11/bin/mvn clean install -DskipTests -f ./ruoyi-common/pom.xml
|
||||
# 通用模块列表(根据项目结构调整)
|
||||
COMMON_MODULES=(
|
||||
"ruoyi-common"
|
||||
"ruoyi-api"
|
||||
"ruoyi-common-bom"
|
||||
"ruoyi-common-alibaba-bom"
|
||||
)
|
||||
for module in "${COMMON_MODULES[@]}"; do
|
||||
POM_PATH="./$module/pom.xml"
|
||||
if [ -f "$POM_PATH" ]; then
|
||||
echo "Building $module..."
|
||||
$MAVEN_HOME/bin/mvn clean install -U -DskipTests -f $POM_PATH
|
||||
else
|
||||
echo "Warning: ruoyi-common module not found"
|
||||
echo "Warning: 通用模块 $module 不存在(路径:$POM_PATH)"
|
||||
fi
|
||||
done
|
||||
|
||||
# API模块
|
||||
if [ -f "./ruoyi-api/pom.xml" ]; then
|
||||
/maven/apache-maven-3.9.11/bin/mvn clean install -DskipTests -f ./ruoyi-api/pom.xml
|
||||
else
|
||||
echo "Warning: ruoyi-api module not found"
|
||||
fi
|
||||
|
||||
# BOM模块
|
||||
if [ -f "./ruoyi-common-bom/pom.xml" ]; then
|
||||
/maven/apache-maven-3.9.11/bin/mvn clean install -DskipTests -f ./ruoyi-common-bom/pom.xml
|
||||
else
|
||||
echo "Warning: ruoyi-common-bom module not found"
|
||||
fi
|
||||
|
||||
# 其他通用模块(根据实际情况添加)
|
||||
# if [ -f "./other-common-module/pom.xml" ]; then
|
||||
# $MAVEN_HOME/bin/mvn clean install -DskipTests -f ./other-common-module/pom.xml
|
||||
# fi
|
||||
|
||||
# 主任务:构建并推送各服务镜像
|
||||
build-and-push:
|
||||
needs: build-common-modules # 依赖通用模块构建完成
|
||||
# 步骤3:分服务构建镜像(依赖通用模块)
|
||||
build-and-push-services:
|
||||
needs: build-common-modules
|
||||
runs-on: ubuntu
|
||||
strategy:
|
||||
matrix:
|
||||
@ -110,55 +128,30 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||||
|
||||
- name: Set up Node.js (if needed)
|
||||
uses: http://git.missmoc.top/mocheng/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
if: ${{ contains(matrix.service, 'frontend') || contains(matrix.service, 'vue') }}
|
||||
|
||||
- name: Set up environment (JDK + Maven)
|
||||
- name: Set up environment
|
||||
run: |
|
||||
# 配置环境变量
|
||||
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
|
||||
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
|
||||
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
||||
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
|
||||
# 验证环境
|
||||
echo "Java version:"
|
||||
java -version
|
||||
echo "Maven version:"
|
||||
$MAVEN_HOME/bin/mvn -v
|
||||
|
||||
- name: Build Project with Maven
|
||||
- name: Build service with Maven (依赖主POM和通用模块)
|
||||
run: |
|
||||
# 检查服务目录是否存在
|
||||
if [ ! -d "./${{ matrix.service }}" ]; then
|
||||
echo "Error: Service directory ${{ matrix.service }} not found"
|
||||
SERVICE_PATH="${{ matrix.service }}"
|
||||
POM_PATH="./$SERVICE_PATH/pom.xml"
|
||||
if [ ! -f "$POM_PATH" ]; then
|
||||
echo "Error: 服务 $SERVICE_PATH 的POM文件不存在"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查pom.xml是否存在
|
||||
if [ ! -f "./${{ matrix.service }}/pom.xml" ]; then
|
||||
echo "Error: pom.xml not found in ${{ matrix.service }}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 执行构建
|
||||
$MAVEN_HOME/bin/mvn clean package -DskipTests -f ./${{ matrix.service }}/pom.xml
|
||||
|
||||
# 检查构建结果
|
||||
if [ ! -d "./${{ matrix.service }}/target" ]; then
|
||||
echo "Error: Build failed, target directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Build successful for ${{ matrix.service }}"
|
||||
ls -la ./${{ matrix.service }}/target/
|
||||
# 构建服务(依赖已安装的主POM和通用模块)
|
||||
$MAVEN_HOME/bin/mvn clean package -U -DskipTests -f $POM_PATH
|
||||
# 检查构建产物
|
||||
ls ./$SERVICE_PATH/target/
|
||||
|
||||
- name: Set Up Docker Buildx
|
||||
uses: http://git.missmoc.top/mocheng/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
- name: Login to Registry
|
||||
uses: http://git.missmoc.top/mocheng/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY_URL }}
|
||||
@ -168,21 +161,12 @@ jobs:
|
||||
- name: Determine Dockerfile Path
|
||||
id: dockerfile-path
|
||||
run: |
|
||||
service_path="${{ matrix.service }}"
|
||||
# 检查默认路径
|
||||
default_dockerfile="$service_path/Dockerfile"
|
||||
# 检查通用路径
|
||||
common_dockerfile="Dockerfile"
|
||||
|
||||
if [ -f "$default_dockerfile" ]; then
|
||||
echo "dockerfile_path=$default_dockerfile" >> $GITHUB_OUTPUT
|
||||
echo "Using Dockerfile at $default_dockerfile"
|
||||
elif [ -f "$common_dockerfile" ]; then
|
||||
echo "dockerfile_path=$common_dockerfile" >> $GITHUB_OUTPUT
|
||||
echo "Using root Dockerfile for $service_path"
|
||||
SERVICE_PATH="${{ matrix.service }}"
|
||||
DOCKERFILE="$SERVICE_PATH/Dockerfile"
|
||||
if [ -f "$DOCKERFILE" ]; then
|
||||
echo "dockerfile_path=$DOCKERFILE" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "Error: Dockerfile not found for $service_path"
|
||||
exit 1
|
||||
echo "dockerfile_path=./Dockerfile" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
@ -192,12 +176,5 @@ jobs:
|
||||
file: ${{ steps.dockerfile-path.outputs.dockerfile_path }}
|
||||
tags: ${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:${{ github.sha }}
|
||||
push: true
|
||||
# 启用缓存加速构建
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
# 构建参数
|
||||
build-args: |
|
||||
SERVICE_NAME=${{ matrix.service }}
|
||||
BUILD_TIMESTAMP=$(date +%Y%m%d%H%M%S)
|
||||
# 显示构建详情
|
||||
progress: plain
|
||||
|
Loading…
Reference in New Issue
Block a user