Skip to content

update actions file #13

update actions file

update actions file #13

Workflow file for this run

name: CI/CD Actions
on:
push:
branches: [ master ] # Branch push edildiginde tetikler
pull_request:
branches: [ master ] # Pull request acildiginda tetikler
jobs:
test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3 # Kodu al
- name: Set up JDK 17
uses: actions/setup-java@v3 # JDK 17'yi yapilandir
with:
java-version: '17'
distribution: 'corretto'
cache: 'maven'
- name: Build with Maven
run: mvn -B package --file pom.xml # Maven ile derle
- name: Cache Maven packages
uses: actions/cache@v3 # Maven paketlerini onbellege al
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Run Tests
run: mvn -B test # Testleri calistir
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 17
cache: 'maven'
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build App
run: mvn -B package --file pom.xml -DskipTests
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push
uses: docker/build-push-action@v5
with:
tags: latest
context: .
dockerfile: Dockerfile
registry: docker.io
push: true
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}