更新 .gitea/workflows/dev.yml
Some checks failed
/ build-and-push (ruoyi-auth) (push) Blocked by required conditions
/ build-and-push (ruoyi-gateway) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/Property) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/Sis) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-gen) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-job) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-resource) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-system) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-workflow) (push) Blocked by required conditions
/ build-and-push (ruoyi-seata-server) (push) Blocked by required conditions
/ build-and-push (ruoyi-sentinel-dashboard) (push) Blocked by required conditions
/ build-and-push (ruoyi-snailjob-server) (push) Blocked by required conditions
/ build-and-push (ruoyi-visual/ruoyi-monitor) (push) Blocked by required conditions
/ build-and-push (ruoyi-visual/ruoyi-nacos) (push) Blocked by required conditions
/ build-common-modules (push) Has been cancelled
Some checks failed
/ build-and-push (ruoyi-auth) (push) Blocked by required conditions
/ build-and-push (ruoyi-gateway) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/Property) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/Sis) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-gen) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-job) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-resource) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-system) (push) Blocked by required conditions
/ build-and-push (ruoyi-modules/ruoyi-workflow) (push) Blocked by required conditions
/ build-and-push (ruoyi-seata-server) (push) Blocked by required conditions
/ build-and-push (ruoyi-sentinel-dashboard) (push) Blocked by required conditions
/ build-and-push (ruoyi-snailjob-server) (push) Blocked by required conditions
/ build-and-push (ruoyi-visual/ruoyi-monitor) (push) Blocked by required conditions
/ build-and-push (ruoyi-visual/ruoyi-nacos) (push) Blocked by required conditions
/ build-common-modules (push) Has been cancelled
This commit is contained in:
parent
dcda333d43
commit
03fc2de13b
@ -1,10 +1,98 @@
|
|||||||
|
#
|
||||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master # 监听master分支
|
- master # 监听master分支
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
# 前置任务:构建并安装项目通用模块(解决内部依赖问题)
|
||||||
|
build-common-modules:
|
||||||
|
runs-on: ubuntu
|
||||||
|
steps:
|
||||||
|
- name: Checkout Repository
|
||||||
|
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up environment (JDK + Maven)
|
||||||
|
run: |
|
||||||
|
# 配置JDK(确保路径与runner中实际安装路径一致)
|
||||||
|
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_HOME/bin/mvn -v
|
||||||
|
echo "JAVA_HOME: $JAVA_HOME"
|
||||||
|
echo "MAVEN_HOME: $MAVEN_HOME"
|
||||||
|
|
||||||
|
- 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>
|
||||||
|
<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>
|
||||||
|
</settings>
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Build and install common modules
|
||||||
|
run: |
|
||||||
|
# 构建并安装项目通用模块(根据实际项目结构调整)
|
||||||
|
# 核心通用模块
|
||||||
|
if [ -f "./ruoyi-common/pom.xml" ]; then
|
||||||
|
$MAVEN_HOME/bin/mvn clean install -DskipTests -f ./ruoyi-common/pom.xml
|
||||||
|
else
|
||||||
|
echo "Warning: ruoyi-common module not found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# API模块
|
||||||
|
if [ -f "./ruoyi-api/pom.xml" ]; then
|
||||||
|
$MAVEN_HOME/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_HOME/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:
|
build-and-push:
|
||||||
|
needs: build-common-modules # 依赖通用模块构建完成
|
||||||
runs-on: ubuntu
|
runs-on: ubuntu
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@ -24,37 +112,53 @@ jobs:
|
|||||||
- ruoyi-sentinel-dashboard
|
- ruoyi-sentinel-dashboard
|
||||||
- ruoyi-snailjob-server
|
- ruoyi-snailjob-server
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Node.js
|
|
||||||
uses: http://git.missmoc.top/mocheng/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: '16' # 指定需要的 Node.js 版本
|
|
||||||
- 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 JDK
|
- name: Set up Node.js (if needed)
|
||||||
# uses: http://git.missmoc.top/mocheng/setup-java@v4
|
uses: http://git.missmoc.top/mocheng/setup-node@v3
|
||||||
# with:
|
with:
|
||||||
# java-version: '17'
|
node-version: '16'
|
||||||
# distribution: 'temurin'
|
if: ${{ contains(matrix.service, 'frontend') || contains(matrix.service, 'vue') }}
|
||||||
|
|
||||||
- name: use JDK
|
- 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
|
|
||||||
|
|
||||||
- name: test jdk
|
|
||||||
run: |
|
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
|
java -version
|
||||||
# 检查 JAVA_HOME 环境变量
|
echo "Maven version:"
|
||||||
echo "JAVA_HOME: $JAVA_HOME"
|
|
||||||
ls $MAVEN_HOME/bin/mvn
|
|
||||||
$MAVEN_HOME/bin/mvn -v
|
$MAVEN_HOME/bin/mvn -v
|
||||||
|
|
||||||
|
|
||||||
- name: Build Project with Maven
|
- name: Build Project with Maven
|
||||||
run: $MAVEN_HOME/bin/mvn clean package -DskipTests -f ./${{ matrix.service }}/pom.xml
|
run: |
|
||||||
|
# 检查服务目录是否存在
|
||||||
|
if [ ! -d "./${{ matrix.service }}" ]; then
|
||||||
|
echo "Error: Service directory ${{ matrix.service }} not found"
|
||||||
|
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/
|
||||||
|
|
||||||
- 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
|
||||||
@ -69,10 +173,21 @@ jobs:
|
|||||||
- name: Determine Dockerfile Path
|
- name: Determine Dockerfile Path
|
||||||
id: dockerfile-path
|
id: dockerfile-path
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ matrix.service }}" = "ruoyi-visual/ruoyi-nacos" ]; then
|
service_path="${{ matrix.service }}"
|
||||||
echo "dockerfile_path=./ruoyi-visual/ruoyi-nacos/Dockerfile" >> $GITHUB_OUTPUT
|
# 检查默认路径
|
||||||
|
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"
|
||||||
else
|
else
|
||||||
echo "dockerfile_path=./${{ matrix.service }}/Dockerfile" >> $GITHUB_OUTPUT
|
echo "Error: Dockerfile not found for $service_path"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Build and Push Docker Image
|
- name: Build and Push Docker Image
|
||||||
@ -82,3 +197,12 @@ 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-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