更新 .gitea/workflows/dev.yml
Some checks failed
/ build-and-push (ruoyi-auth) (push) Failing after 21s
/ build-and-push (ruoyi-modules/Property) (push) Failing after 21s
/ build-and-push (ruoyi-modules/Sis) (push) Failing after 22s
/ build-and-push (ruoyi-modules/ruoyi-gen) (push) Failing after 21s
/ build-and-push (ruoyi-modules/ruoyi-job) (push) Failing after 22s
/ build-and-push (ruoyi-modules/ruoyi-resource) (push) Failing after 20s
/ build-and-push (ruoyi-modules/ruoyi-system) (push) Failing after 21s
/ build-and-push (ruoyi-modules/ruoyi-workflow) (push) Failing after 21s
/ build-and-push (ruoyi-seata-server) (push) Failing after 21s
/ build-and-push (ruoyi-snailjob-server) (push) Waiting to run
/ build-and-push (ruoyi-visual/ruoyi-monitor) (push) Waiting to run
/ build-and-push (ruoyi-visual/ruoyi-nacos) (push) Waiting to run
/ build-and-push (ruoyi-gateway) (push) Has been cancelled
/ build-and-push (ruoyi-sentinel-dashboard) (push) Has been cancelled
Some checks failed
/ build-and-push (ruoyi-auth) (push) Failing after 21s
/ build-and-push (ruoyi-modules/Property) (push) Failing after 21s
/ build-and-push (ruoyi-modules/Sis) (push) Failing after 22s
/ build-and-push (ruoyi-modules/ruoyi-gen) (push) Failing after 21s
/ build-and-push (ruoyi-modules/ruoyi-job) (push) Failing after 22s
/ build-and-push (ruoyi-modules/ruoyi-resource) (push) Failing after 20s
/ build-and-push (ruoyi-modules/ruoyi-system) (push) Failing after 21s
/ build-and-push (ruoyi-modules/ruoyi-workflow) (push) Failing after 21s
/ build-and-push (ruoyi-seata-server) (push) Failing after 21s
/ build-and-push (ruoyi-snailjob-server) (push) Waiting to run
/ build-and-push (ruoyi-visual/ruoyi-monitor) (push) Waiting to run
/ build-and-push (ruoyi-visual/ruoyi-nacos) (push) Waiting to run
/ build-and-push (ruoyi-gateway) (push) Has been cancelled
/ build-and-push (ruoyi-sentinel-dashboard) (push) Has been cancelled
This commit is contained in:
parent
269c105282
commit
afc0e69319
@ -1,80 +1,13 @@
|
||||
run-name: ${{ gitea.actor }} 构建并推送服务镜像 🚀
|
||||
run-name: ${{ gitea.actor }} 打包并构建镜像 🚀
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
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
|
||||
build-and-push:
|
||||
runs-on: ubuntu
|
||||
strategy:
|
||||
fail-fast: false # 单个服务失败不影响其他服务构建
|
||||
matrix:
|
||||
service:
|
||||
- ruoyi-auth
|
||||
@ -95,25 +28,84 @@ jobs:
|
||||
- name: 拉取代码仓库
|
||||
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||||
|
||||
- name: 配置Docker Buildx构建环境
|
||||
- name: 配置环境变量
|
||||
run: |
|
||||
# 配置JDK和Maven绝对路径
|
||||
export JAVA_HOME="/java17/java17"
|
||||
export MAVEN_HOME="/maven/apache-maven-3.9.11"
|
||||
|
||||
# 验证路径有效性
|
||||
if [ ! -f "$JAVA_HOME/bin/java" ]; then
|
||||
echo "错误:JDK不存在于 $JAVA_HOME"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$MAVEN_HOME/bin/mvn" ]; then
|
||||
echo "错误:Maven不存在于 $MAVEN_HOME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 配置环境变量
|
||||
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: |
|
||||
mkdir -p ~/.m2
|
||||
cat > ~/.m2/settings.xml << EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<settings>
|
||||
<localRepository>$HOME/.m2/repository</localRepository>
|
||||
<mirrors>
|
||||
<mirror>
|
||||
<id>huawei</id>
|
||||
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
|
||||
<mirrorOf>*</mirrorOf>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
</settings>
|
||||
EOF
|
||||
|
||||
- name: 执行mvn clean package打包
|
||||
run: |
|
||||
SERVICE_NAME="${{ matrix.service }}"
|
||||
POM_PATH="${GITHUB_WORKSPACE}/${SERVICE_NAME}/pom.xml"
|
||||
|
||||
# 检查POM文件是否存在
|
||||
if [ ! -f "$POM_PATH" ]; then
|
||||
echo "错误:$SERVICE_NAME 的POM文件不存在于 $POM_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 直接执行打包命令
|
||||
mvn clean package -U -DskipTests -f "$POM_PATH"
|
||||
|
||||
# 验证打包结果
|
||||
echo "=== 打包产物 ==="
|
||||
ls -la "${GITHUB_WORKSPACE}/${SERVICE_NAME}/target/"
|
||||
|
||||
- name: 配置Docker Buildx
|
||||
uses: http://git.missmoc.top/mocheng/setup-buildx-action@v3
|
||||
|
||||
- name: 登录到容器仓库
|
||||
- name: 登录容器仓库
|
||||
uses: http://git.missmoc.top/mocheng/login-action@v3
|
||||
with:
|
||||
registry: ${{ secrets.REGISTRY_URL }}
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASS }}
|
||||
|
||||
- name: 构建并推送服务镜像
|
||||
- name: 构建并推送Docker镜像
|
||||
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 # 最大化缓存内容
|
||||
context: "${GITHUB_WORKSPACE}"
|
||||
file: "${{ matrix.service }}/Dockerfile"
|
||||
tags: ${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:${{ github.sha }}
|
||||
push: true
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
Loading…
Reference in New Issue
Block a user