Skip to content

configuring not found jdk changing it with java@v1 #12

configuring not found jdk changing it with java@v1

configuring not found jdk changing it with java@v1 #12

name: BSN Backend API Pipeline
on:
push:
branches:
- ci/pipeline
paths:
- SocialBooksAppBackend/**
- docker/backend/**
- 'docker-compose.yml'
- .github/workflows/*-backend.yml
jobs:
compile:
runs-on: ubuntu-20.04
name: Compile project
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java
with:
java-version: 17
distribution: 'corretto'
- name: Compile project
run: |
cd SocialBooksAppBackend
./mvnw clean compile
unit-tests:
runs-on: ubuntu-20.04
name: Unit tests
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java
with:
java-version: 17
distribution: 'corretto'
- name: Running unit Tests
run: |
cd SocialBooksAppBackend
./mvnw clean test
build:
runs-on: ubuntu-20.04
name: Build backend
needs: [compile, unit-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-jdk@v4
with:
java-version: 17
distribution: 'corretto'
- name: Build project
run: |
cd SocialBooksAppBackend
./mvnw clean package
build-image:
runs-on: ubuntu-20.04
name: Build Docker Image
needs: [build]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-jdk@v4
with:
java-version: 17
distribution: 'corretto'
- name: Extract project version
id: extract_version
run: |
cd SocialBooksAppBackend
echo "JAR_VERSION=$(./mvnw -q -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push to DockerHub
uses: docker/build-push-action@v5
with:
context: SocialBooksAppBackend
file: docker/backend/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ secrets.DOCKERHUB_USERNAME }}/bsn-api:${{ env.JAR_VERSION }},${{ secrets.DOCKERHUB_USERNAME }}/bsn-api:latest
build-args: |
ACTIVE_PROFILE=dev
JAR_VERSION=${{ env.JAR_VERSION }}
deploy:
name: Deploy Backend
runs-on: ubuntu-20.04
needs: [ build-image ]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create environment file
run: |
echo "MAIL_USERNAME=${{ secrets.MAIL_USERNAME }}" >> .env
echo "MAIL_PASSWORD=${{ secrets.MAIL_PASSWORD }}" >> .env
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .env
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> .env
echo "TOKEN_EXPIRATION=${{ secrets.TOKEN_EXPIRATION }}" >> .env
echo "TOKEN_KEY=${{ secrets.TOKEN_KEY }}" >> .env
echo "DB_URL=${{ secrets.DB_URL }}" >> .env
echo "ACTIVE_PROFILE=${{ secrets.ACTIVE_PROFILE }}" >> .env
echo "JAR_VERSION=${{ secrets.JAR_VERSION }}" >> .env
- name: Deploy with Docker Compose
run: |
docker compose -f docker-compose.yml pull -q
docker compose -f docker-compose.yml up -d --build