name: 编译项目

on:
  push:
    branches: [ main, master ]
    paths-ignore:
      - 'bin/**'
      - '.github/**'
      - '.mvn/**'
      - '.run/**'
      - '.vscode/**'
      - '*.txt'
      - '*.md'
  pull_request:
    branches: [ main, master ]

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
    - name: 检出代码
      uses: actions/checkout@v4
      
    - name: 设置 Java 17
      uses: actions/setup-java@v4
      with:
        java-version: '17'
        distribution: 'temurin'
        
    - name: 缓存 Maven 依赖
      uses: actions/cache@v3
      with:
        path: ~/.m2
        key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
        restore-keys: ${{ runner.os }}-m2
        
    - name: 编译项目
      run: ./mvnw clean compile
      
#    - name: 运行测试
#      run: ./mvnw test
      
    - name: 打包项目
      run: ./mvnw package -DskipTests
