更新 .gitea/workflows/dev.yml
This commit is contained in:
@@ -1,51 +1,66 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
name: Build and Push Microservices Images
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ] # 当main分支有推送时触发
|
||||
branches:
|
||||
- [ master ] # 替换为要监听的分支
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
build-and-push:
|
||||
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:
|
||||
|
||||
- name: Checkout code
|
||||
uses: http://47.109.37.87:3000/bichangxiong/checkout@v4 # 使用 Gitea 镜像
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set Up JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
fetch-depth: 1 # 只拉取最新一次提交
|
||||
# - 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'
|
||||
java-version: '11' # 按项目实际Java版本调整
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
- name: Set up Maven
|
||||
uses: stCarolas/setup-maven@v5
|
||||
with:
|
||||
maven-version: 3.8.2
|
||||
|
||||
- name: Install dependencies
|
||||
run: mvn clean package -DskipTests -Dmaven.repo.local=/home/runner/maven-repo
|
||||
- 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: Build Project with Maven
|
||||
run: mvn clean package -DskipTests -f ./${{ matrix.service }}/pom.xml
|
||||
|
||||
- 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
|
Reference in New Issue
Block a user