Upgrade versions #174
This file contains 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: Maven Build | |
on: | |
push: | |
branches: | |
- 'main' | |
jobs: | |
build: | |
name: Maven Build | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_IMAGE_NAME: ${{ secrets.DOCKER_USERNAME }}/spring-boot-todolist | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Build with Maven | |
run: ./mvnw -ntp verify | |
- if: ${{ github.ref == 'refs/heads/main' }} | |
name: SonarCloud Scan | |
run: ./mvnw compile sonar:sonar -Dsonar.token=${{ secrets.SONAR_TOKEN }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- if: ${{ github.ref == 'refs/heads/main' }} | |
name: Build and Publish Docker Image | |
run: | | |
./mvnw -DskipTests spring-boot:build-image -Dspring-boot.build-image.imageName=$DOCKER_IMAGE_NAME | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker push $DOCKER_IMAGE_NAME |