while1618 started CI #206
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@v4 | |
| - name: Set up JDK 25 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: "25" | |
| distribution: "temurin" | |
| cache: maven | |
| - name: Build | |
| run: ./mvnw -B clean install -DskipTests | |
| - name: Lint | |
| run: ./mvnw -B spotless:check | |
| - name: Unit tests | |
| run: ./mvnw -B test | |
| - name: Integration tests | |
| run: ./mvnw -B failsafe:integration-test failsafe:verify | |
| push-image: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - 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@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| 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 |