Skip to content

hello-spring-ci

hello-spring-ci #3

name: Hello Spring Boot App to Docker
on:
push
jobs:
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
- name: Build and Test (Maven)
working-directory: docker/app1-hello/springboot/hello-spring
run: mvn -B clean verify
- name: Upload Test Reports
uses: actions/upload-artifact@v4
with:
name: test-reports
path: docker/app1-hello/springboot/hello-spring/target/surefire-reports
docker-build-push:
runs-on: ubuntu-latest
needs: build-test
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup JDK
uses: actions/setup-java@v5
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '21'
- name: Build JAR for Docker
working-directory: docker/app1-hello/springboot/hello-spring
run: mvn -B clean package -DskipTests
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: docker/app1-hello/springboot/hello-spring
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/hello-spring:latest
${{ secrets.DOCKER_USERNAME }}/hello-spring:{{ github.sha }}
${{ secrets.DOCKER_USERNAME }}/hello-spring:{{ github.ref_name }}