Skip to content
32 changes: 13 additions & 19 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,36 @@ name: Java CI with Docker

on:
push:
branches: [ "develop", "main" ]
pull_request:
branches: [ "develop", "main" ]
branches: [ "develop", "master" ]

jobs:
build-and-test:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
distribution: 'temurin'
java-version: '17'
cache: 'maven'

- name: Build with Maven
run: mvn clean package --file pom.xml

docker:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout repo
uses: actions/checkout@v3
run: mvn clean package -DskipTests

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker Image
run: docker build -t mustafaguler4/spring-ecommerce-app:${{ github.sha }} .

- name: Push Docker Image
run: docker push mustafaguler4/spring-ecommerce-app:${{ github.sha }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
mustafaguler4/spring-ecommerce-app:latest
mustafaguler4/spring-ecommerce-app:${{ github.sha }}
Loading