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
180 lines
6.4 KiB
YAML
180 lines
6.4 KiB
YAML
run-name: ${{ gitea.actor }} is building with parent POM first 🚀
|
||
on:
|
||
push:
|
||
branches:
|
||
- master
|
||
|
||
jobs:
|
||
# 步骤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
|
||
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
||
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
|
||
java -version
|
||
$MAVEN_HOME/bin/mvn -v
|
||
|
||
- name: Configure Maven settings (本地优先 + 官方仓库)
|
||
run: |
|
||
mkdir -p ~/.m2
|
||
cat > ~/.m2/settings.xml << EOF
|
||
<?xml version="1.0" encoding="UTF-8"?>
|
||
<settings>
|
||
<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>
|
||
</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: |
|
||
# 通用模块列表(根据项目结构调整)
|
||
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: 通用模块 $module 不存在(路径:$POM_PATH)"
|
||
fi
|
||
done
|
||
|
||
# 步骤3:分服务构建镜像(依赖通用模块)
|
||
build-and-push-services:
|
||
needs: build-common-modules
|
||
runs-on: ubuntu
|
||
strategy:
|
||
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: 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 service with Maven (依赖主POM和通用模块)
|
||
run: |
|
||
SERVICE_PATH="${{ matrix.service }}"
|
||
POM_PATH="./$SERVICE_PATH/pom.xml"
|
||
if [ ! -f "$POM_PATH" ]; then
|
||
echo "Error: 服务 $SERVICE_PATH 的POM文件不存在"
|
||
exit 1
|
||
fi
|
||
# 构建服务(依赖已安装的主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 Registry
|
||
uses: http://git.missmoc.top/mocheng/login-action@v3
|
||
with:
|
||
registry: ${{ secrets.REGISTRY_URL }}
|
||
username: ${{ secrets.REGISTRY_USER }}
|
||
password: ${{ secrets.REGISTRY_PASS }}
|
||
|
||
- name: Determine Dockerfile Path
|
||
id: dockerfile-path
|
||
run: |
|
||
SERVICE_PATH="${{ matrix.service }}"
|
||
DOCKERFILE="$SERVICE_PATH/Dockerfile"
|
||
if [ -f "$DOCKERFILE" ]; then
|
||
echo "dockerfile_path=$DOCKERFILE" >> $GITHUB_OUTPUT
|
||
else
|
||
echo "dockerfile_path=./Dockerfile" >> $GITHUB_OUTPUT
|
||
fi
|
||
|
||
- name: Build and Push Docker Image
|
||
uses: http://git.missmoc.top/mocheng/build-push-action@v5
|
||
with:
|
||
context: .
|
||
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 |