feat(build): 更新Java版本配置并优化CI流程 #1093
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will build a Java project with Maven | |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
| name: maven 编译检查 | |
| on: | |
| push: | |
| branches: [ master,dev ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| java-version: [ 17,21,25 ] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK ${{ matrix.java-version }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.java-version }} | |
| distribution: 'zulu' | |
| - name: mvn spring-javaformat:validate | |
| id: validate | |
| run: mvn spring-javaformat:validate -Dmaven.compiler.release=${{ matrix.java-version }} | |
| continue-on-error: true | |
| - name: Auto format code if validation fails | |
| if: steps.validate.outcome == 'failure' | |
| run: mvn spring-javaformat:apply -Dmaven.compiler.release=${{ matrix.java-version }} | |
| - name: Create Pull Request for formatting changes | |
| if: steps.validate.outcome == 'failure' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: 'Auto-format code with spring-javaformat' | |
| title: 'Auto-format: Fix code formatting issues' | |
| body: | | |
| This PR was automatically created because the spring-javaformat validation failed. | |
| The following changes have been applied: | |
| - Applied spring-javaformat:apply to fix formatting issues | |
| Please review and merge if the changes look correct. | |
| branch: auto-format-${{ github.run_number }} | |
| delete-branch: true | |
| - name: mvn clean install | |
| run: mvn clean install -Pboot -Dmaven.compiler.release=${{ matrix.java-version }} | |
| - name: mvn clean install | |
| run: mvn clean install -Dmaven.compiler.release=${{ matrix.java-version }} | |
| - name: failure | |
| if: failure() && github.repository == 'pig-mesh/pig' | |
| uses: chf007/action-wechat-work@master | |
| env: | |
| WECHAT_WORK_BOT_WEBHOOK: ${{secrets.WECHAT_WORK_BOT_WEBHOOK}} | |
| with: | |
| msgtype: markdown | |
| content: | | |
| # 💤🤷♀️ failure 🙅♂️💣 [pig-mesh/pig](https://github.com/pig-mesh/pig) | |
| > Github Action: https://github.com/pig-mesh/pig failure | |
| > (⋟﹏⋞) from github action message |