更新 .gitea/workflows/dev.yml

This commit is contained in:
2025-08-13 15:37:20 +08:00
parent 89041e783b
commit 2ffeb25d82

View File

@@ -1,51 +1,66 @@
name: Gitea Actions Demo name: Build and Push Microservices Images
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: on:
push: push:
branches: [ master ] # 当main分支有推送时触发 branches:
- [ master ] # 替换为要监听的分支
jobs: jobs:
Explore-Gitea-Actions: build-and-push:
runs-on: ubuntu-latest runs-on: ubuntu-latest
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: steps:
- name: Checkout Repository
- name: Checkout code uses: actions/checkout@v3
uses: http://47.109.37.87:3000/bichangxiong/checkout@v4 # 使用 Gitea 镜像
- name: Set Up JDK
uses: actions/setup-java@v3
with: with:
fetch-depth: 1 # 只拉取最新一次提交 java-version: '11' # 按项目实际Java版本调整
# - name: Checkout code
# uses: actions/checkout@v4 # 拉取代码到工作目录
- name: Set up JDK 17
uses: http://47.109.37.87:3000/bichangxiong/setup-java@v3
with:
java-version: '17'
distribution: 'temurin' distribution: 'temurin'
cache: maven
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.8.2
- name: Install dependencies - name: Build Project with Maven
run: mvn clean package -DskipTests -Dmaven.repo.local=/home/runner/maven-repo run: mvn clean package -DskipTests -f ./${{ matrix.service }}/pom.xml
- name: copy file via ssh password
uses: appleboy/scp-action@v0.1.7
with:
host: 192.168.1.3
username: root
password: by@2025!
port: 22
source: "ruoyi-modules/Property/target/Property.jar,ruoyi-modules/Property/docker-compose.yml,ruoyi-modules/Property/Dockerfile"
target: "/project/runner/plus/"
- name: Deploy to server via SSH
uses: appleboy/ssh-action@v0.1.7
with:
host: 192.168.1.3
username: root
password: by@2025!
port: 22
script: |
cd /project/runner/plus/ruoyi-modules/Property
docker-compose up -d --force-recreate
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2
- run: echo "🍏 This job's status is ${{ job.status }}." - name: Login to Gitea Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: Determine Dockerfile Path
id: dockerfile-path
run: |
if [ "${{ matrix.service }}" = "ruoyi-visual/ruoyi-nacos" ]; then
echo "dockerfile_path=./ruoyi-visual/ruoyi-nacos/Dockerfile" >> $GITHUB_OUTPUT
else
echo "dockerfile_path=./${{ matrix.service }}/Dockerfile" >> $GITHUB_OUTPUT
fi
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: ${{ steps.dockerfile-path.outputs.dockerfile_path }}
tags: ${{ secrets.REGISTRY_URL }}/by2025/${{ matrix.service }}:${{ github.sha }}
push: true