更新 .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:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master # 监听master分支
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-common-modules:
|
# 步骤1:构建项目主POM(父模块),安装到本地仓库
|
||||||
|
build-parent-pom:
|
||||||
runs-on: ubuntu
|
runs-on: ubuntu
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: http://git.missmoc.top/mocheng/checkout@v4
|
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||||||
|
|
||||||
- name: Set up environment (JDK + Maven)
|
- name: Set up environment (JDK + Maven)
|
||||||
run: |
|
run: |
|
||||||
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
|
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
|
||||||
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
|
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
|
||||||
# 配置Maven
|
|
||||||
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
||||||
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
|
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
|
||||||
echo "Java version:"
|
|
||||||
java -version
|
java -version
|
||||||
echo "Maven version:"
|
$MAVEN_HOME/bin/mvn -v
|
||||||
/maven/apache-maven-3.9.11/bin/mvn -v
|
|
||||||
echo "JAVA_HOME: $JAVA_HOME"
|
|
||||||
echo "MAVEN_HOME: $MAVEN_HOME"
|
|
||||||
|
|
||||||
- name: Configure Maven settings
|
- name: Configure Maven settings (本地优先 + 官方仓库)
|
||||||
run: |
|
run: |
|
||||||
# 创建Maven配置文件,添加必要仓库
|
|
||||||
mkdir -p ~/.m2
|
mkdir -p ~/.m2
|
||||||
cat > ~/.m2/settings.xml << EOF
|
cat > ~/.m2/settings.xml << EOF
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<settings>
|
<settings>
|
||||||
<mirrors>
|
<localRepository>${user.home}/.m2/repository</localRepository>
|
||||||
<!-- Maven中央仓库 -->
|
<profiles>
|
||||||
<mirror>
|
<profile>
|
||||||
<id>central</id>
|
<id>local-first</id>
|
||||||
<url>https://repo1.maven.org/maven2</url>
|
<repositories>
|
||||||
<mirrorOf>central</mirrorOf>
|
<repository>
|
||||||
</mirror>
|
<id>local-repo</id>
|
||||||
<!-- Dromara官方仓库 -->
|
<url>file://${user.home}/.m2/repository</url>
|
||||||
<mirror>
|
<releases><enabled>true</enabled></releases>
|
||||||
<id>dromara-repo</id>
|
<snapshots><enabled>true</enabled></snapshots>
|
||||||
<url>https://maven.dromara.org/repository/releases/</url>
|
</repository>
|
||||||
<mirrorOf>dromara</mirrorOf>
|
<repository>
|
||||||
</mirror>
|
<id>dromara-releases</id>
|
||||||
<!-- 内部仓库(如有请取消注释并修改地址) -->
|
<url>https://maven.dromara.org/repository/releases/</url>
|
||||||
<!--
|
</repository>
|
||||||
<mirror>
|
<repository>
|
||||||
<id>internal-repo</id>
|
<id>public</id>
|
||||||
<url>http://your-internal-repo-url/maven-releases/</url>
|
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
|
||||||
<mirrorOf>internal</mirrorOf>
|
<releases><enabled>false</enabled></releases>
|
||||||
</mirror>
|
</repository>
|
||||||
-->
|
</repositories>
|
||||||
</mirrors>
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
<activeProfiles>
|
||||||
|
<activeProfile>local-first</activeProfile>
|
||||||
|
</activeProfiles>
|
||||||
</settings>
|
</settings>
|
||||||
EOF
|
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
|
- name: Build and install common modules
|
||||||
run: |
|
run: |
|
||||||
# 构建并安装项目通用模块(根据实际项目结构调整)
|
# 通用模块列表(根据项目结构调整)
|
||||||
# 核心通用模块
|
COMMON_MODULES=(
|
||||||
if [ -f "./ruoyi-common/pom.xml" ]; then
|
"ruoyi-common"
|
||||||
/maven/apache-maven-3.9.11/bin/mvn clean install -DskipTests -f ./ruoyi-common/pom.xml
|
"ruoyi-api"
|
||||||
else
|
"ruoyi-common-bom"
|
||||||
echo "Warning: ruoyi-common module not found"
|
"ruoyi-common-alibaba-bom"
|
||||||
fi
|
)
|
||||||
|
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
|
||||||
|
|
||||||
# API模块
|
# 步骤3:分服务构建镜像(依赖通用模块)
|
||||||
if [ -f "./ruoyi-api/pom.xml" ]; then
|
build-and-push-services:
|
||||||
/maven/apache-maven-3.9.11/bin/mvn clean install -DskipTests -f ./ruoyi-api/pom.xml
|
needs: build-common-modules
|
||||||
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 # 依赖通用模块构建完成
|
|
||||||
runs-on: ubuntu
|
runs-on: ubuntu
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@ -110,55 +128,30 @@ jobs:
|
|||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: http://git.missmoc.top/mocheng/checkout@v4
|
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||||||
|
|
||||||
- name: Set up Node.js (if needed)
|
- name: Set up environment
|
||||||
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)
|
|
||||||
run: |
|
run: |
|
||||||
# 配置环境变量
|
|
||||||
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
|
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
|
||||||
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
|
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
|
||||||
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
echo "MAVEN_HOME=/maven/apache-maven-3.9.11" >> $GITHUB_ENV
|
||||||
echo "$MAVEN_HOME/bin" >> $GITHUB_PATH
|
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: |
|
run: |
|
||||||
# 检查服务目录是否存在
|
SERVICE_PATH="${{ matrix.service }}"
|
||||||
if [ ! -d "./${{ matrix.service }}" ]; then
|
POM_PATH="./$SERVICE_PATH/pom.xml"
|
||||||
echo "Error: Service directory ${{ matrix.service }} not found"
|
if [ ! -f "$POM_PATH" ]; then
|
||||||
|
echo "Error: 服务 $SERVICE_PATH 的POM文件不存在"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
# 构建服务(依赖已安装的主POM和通用模块)
|
||||||
# 检查pom.xml是否存在
|
$MAVEN_HOME/bin/mvn clean package -U -DskipTests -f $POM_PATH
|
||||||
if [ ! -f "./${{ matrix.service }}/pom.xml" ]; then
|
# 检查构建产物
|
||||||
echo "Error: pom.xml not found in ${{ matrix.service }}"
|
ls ./$SERVICE_PATH/target/
|
||||||
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/
|
|
||||||
|
|
||||||
- name: Set Up Docker Buildx
|
- name: Set Up Docker Buildx
|
||||||
uses: http://git.missmoc.top/mocheng/setup-buildx-action@v3
|
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
|
uses: http://git.missmoc.top/mocheng/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ secrets.REGISTRY_URL }}
|
registry: ${{ secrets.REGISTRY_URL }}
|
||||||
@ -168,21 +161,12 @@ jobs:
|
|||||||
- name: Determine Dockerfile Path
|
- name: Determine Dockerfile Path
|
||||||
id: dockerfile-path
|
id: dockerfile-path
|
||||||
run: |
|
run: |
|
||||||
service_path="${{ matrix.service }}"
|
SERVICE_PATH="${{ matrix.service }}"
|
||||||
# 检查默认路径
|
DOCKERFILE="$SERVICE_PATH/Dockerfile"
|
||||||
default_dockerfile="$service_path/Dockerfile"
|
if [ -f "$DOCKERFILE" ]; then
|
||||||
# 检查通用路径
|
echo "dockerfile_path=$DOCKERFILE" >> $GITHUB_OUTPUT
|
||||||
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"
|
|
||||||
else
|
else
|
||||||
echo "Error: Dockerfile not found for $service_path"
|
echo "dockerfile_path=./Dockerfile" >> $GITHUB_OUTPUT
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
@ -192,12 +176,5 @@ jobs:
|
|||||||
file: ${{ steps.dockerfile-path.outputs.dockerfile_path }}
|
file: ${{ steps.dockerfile-path.outputs.dockerfile_path }}
|
||||||
tags: ${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:${{ github.sha }}
|
tags: ${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:${{ github.sha }}
|
||||||
push: true
|
push: true
|
||||||
# 启用缓存加速构建
|
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
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