SmartParks/.gitea/workflows/dev.yml
bichangxiong 22dadcfdd9
Some checks failed
/ build-parent-pom (push) Failing after 16s
/ 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
更新 .gitea/workflows/dev.yml
2025-08-14 01:08:21 +08:00

181 lines
6.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

run-name: ${{ gitea.actor }} is building with parent POM first 🚀
on:
push:
branches:
- master
jobs:
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: |
# 配置 JDK确认路径正确与实际安装一致
echo "JAVA_HOME=/java17/java17" >> $GITHUB_ENV
echo "$JAVA_HOME/bin" >> $GITHUB_PATH
# 修复 Maven 路径:先确认 runner 中 Maven 的实际安装位置
# 常见路径:/usr/local/maven、/opt/maven、/maven 等,根据实际情况修改
MAVEN_ACTUAL_PATH="/maven/apache-maven-3.9.11" # 关键:替换为 runner 中 Maven 的真实路径
# 验证 Maven 可执行文件是否存在
if [ ! -f "$MAVEN_ACTUAL_PATH/bin/mvn" ]; then
echo "Error: Maven 可执行文件不存在于 $MAVEN_ACTUAL_PATH/bin/mvn"
exit 1
fi
# 配置 Maven 环境变量
echo "MAVEN_HOME=$MAVEN_ACTUAL_PATH" >> $GITHUB_ENV
echo "$MAVEN_ACTUAL_PATH/bin" >> $GITHUB_PATH
# 验证配置
echo "Java 版本:"
java -version
echo "Maven 版本:"
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>
</repository>
<repository>
<id>dromara-releases</id>
<url>https://maven.dromara.org/repository/releases/</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>local-first</activeProfile>
</activeProfiles>
</settings>
EOF
- name: Build and install parent POM
run: |
MAIN_POM_PATH="./pom.xml"
if [ ! -f "$MAIN_POM_PATH" ]; then
echo "Error: 主POM文件不存在"
exit 1
fi
mvn clean install -N -U -DskipTests -f $MAIN_POM_PATH
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
MAVEN_ACTUAL_PATH="/maven/apache-maven-3.9.11" # 与上文一致
echo "MAVEN_HOME=$MAVEN_ACTUAL_PATH" >> $GITHUB_ENV
echo "$MAVEN_ACTUAL_PATH/bin" >> $GITHUB_PATH
mvn -v # 验证
- name: Build and install common modules
run: |
COMMON_MODULES=(
"ruoyi-common"
"ruoyi-api"
"ruoyi-common-bom"
)
for module in "${COMMON_MODULES[@]}"; do
POM_PATH="./$module/pom.xml"
if [ -f "$POM_PATH" ]; then
mvn clean install -U -DskipTests -f $POM_PATH
else
echo "Warning: 模块 $module 不存在"
fi
done
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
MAVEN_ACTUAL_PATH="/maven/apache-maven-3.9.11" # 与上文一致
echo "MAVEN_HOME=$MAVEN_ACTUAL_PATH" >> $GITHUB_ENV
echo "$MAVEN_ACTUAL_PATH/bin" >> $GITHUB_PATH
mvn -v # 验证
- name: Build service with Maven
run: |
SERVICE_PATH="${{ matrix.service }}"
POM_PATH="./$SERVICE_PATH/pom.xml"
if [ ! -f "$POM_PATH" ]; then
echo "Error: POM文件不存在"
exit 1
fi
mvn clean package -U -DskipTests -f $POM_PATH
- 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