while1618 started CI #212
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
| name: Spring Boot CI | |
| run-name: ${{ github.actor }} started CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [master] | |
| paths: | |
| - backend/spring-boot/** | |
| pull_request: | |
| branches: [master] | |
| paths: | |
| - backend/spring-boot/** | |
| jobs: | |
| build: | |
| defaults: | |
| run: | |
| working-directory: backend/spring-boot | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: "25" | |
| distribution: "temurin" | |
| cache: maven | |
| - name: Lint | |
| run: ./mvnw -B spotless:check | |
| - name: Test | |
| run: ./mvnw -B clean verify | |
| - name: Upload JaCoCo report | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: jacoco-report | |
| path: backend/spring-boot/target/site/jacoco/ | |
| push-image: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Install xmllint | |
| run: sudo apt install -y libxml2-utils | |
| - name: Get api version | |
| id: api-version | |
| run: | | |
| VERSION=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" backend/spring-boot/pom.xml | sed 's/-SNAPSHOT//') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: backend/spring-boot | |
| file: backend/spring-boot/Dockerfile | |
| target: prod | |
| push: true | |
| tags: | | |
| ${{ vars.DOCKER_REPOSITORY_API }}:${{ steps.api-version.outputs.version }} | |
| ${{ vars.DOCKER_REPOSITORY_API }}:latest |