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
111 lines
3.5 KiB
YAML
111 lines
3.5 KiB
YAML
run-name: ${{ gitea.actor }} 打包并构建镜像 🚀
|
||
on:
|
||
push:
|
||
branches:
|
||
- master
|
||
|
||
jobs:
|
||
build-and-push:
|
||
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: 拉取代码仓库
|
||
uses: http://git.missmoc.top/mocheng/checkout@v4
|
||
|
||
- 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: 登录容器仓库
|
||
uses: http://git.missmoc.top/mocheng/login-action@v3
|
||
with:
|
||
registry: ${{ secrets.REGISTRY_URL }}
|
||
username: ${{ secrets.REGISTRY_USER }}
|
||
password: ${{ secrets.REGISTRY_PASS }}
|
||
|
||
- name: 构建并推送Docker镜像
|
||
uses: http://git.missmoc.top/mocheng/build-push-action@v5
|
||
with:
|
||
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
|
||
|