Skip to content

Merge pull request #20 from bouanani-soufiane/PIG-64-Lofts #42

Merge pull request #20 from bouanani-soufiane/PIG-64-Lofts

Merge pull request #20 from bouanani-soufiane/PIG-64-Lofts #42

Workflow file for this run

name: Spring Boot CI/CD Pipeline
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
DOCKER_HUB_REPO: ${{ secrets.DOCKER_HUB_USERNAME }}/springboot-app
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn clean package -DskipTests
- name: Run tests
run: mvn test
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push Docker images
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ env.DOCKER_HUB_REPO }}:latest
${{ env.DOCKER_HUB_REPO }}:${{ github.sha }}
cache-from: type=registry,ref=${{ env.DOCKER_HUB_REPO }}:buildcache
cache-to: type=registry,ref=${{ env.DOCKER_HUB_REPO }}:buildcache,mode=max