SmartParks/.gitea/workflows/dev.yml
Workflow config file is invalid. Please check your config file: yaml: unmarshal errors: line 113: cannot unmarshal !!seq into string

115 lines
3.7 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 }} 构建并推送服务镜像 🚀
on:
push:
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
- name: 配置Maven仓库
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>aliyun</id>
<repositories>
<repository>
<id>aliyun</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
# 查看构建产物
find . -name "*.jar" -path "*/target/*"
# 阶段2为每个服务构建并推送镜像
build-images:
needs: build-all
runs-on: ubuntu
strategy:
fail-fast: false
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: 配置Docker构建环境
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: 构建并推送镜像
uses: http://git.missmoc.top/mocheng/build-push-action@v5
with:
context: .
file: ./${{ matrix.service }}/Dockerfile
tags: |
${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:${{ github.sha }}
${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:latest
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
# 仅当Dockerfile或相关目录变化时构建
paths:
- ${{ matrix.service }}/**
- pom.xml