diff --git a/.github/workflows/build-push-docker.yml b/.github/workflows/build-push-docker.yml index 5de2968..34c715f 100644 --- a/.github/workflows/build-push-docker.yml +++ b/.github/workflows/build-push-docker.yml @@ -1,10 +1,18 @@ +# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. name: Build and Publish Docker Image on: release: - types: [created] + types: [created, published] version: 'v*.*.*' + jobs: build: @@ -15,11 +23,11 @@ jobs: env: POSTGRES_USER: postgres POSTGRES_PASSWORD: 1234 - POSTGRES_DB: mini-pms + POSTGRES_DB: pms-db ports: - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + steps: - uses: actions/checkout@v3 - name: Set up JDK 17 @@ -53,7 +61,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: ./Dockerfile + file: ./backend/pms/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d463b0f..9ce148c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,8 +11,13 @@ name: Test and Build on: push: branches: [ "main" ] + paths: + - 'backend/**' pull_request: branches: [ "main" ] + paths: + - 'backend/**' + jobs: build: @@ -37,9 +42,36 @@ jobs: java-version: '17' distribution: 'temurin' cache: maven - # - name: Run Tests - # run: cd backend/pms && mvn test - name: Build with Maven run: cd backend/pms && mvn clean package + - name: Build with Maven + run: cd backend/pms && mvn clean package + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/mini-pms + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./backend/pms + file: ./backend/pms/Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/backend/pms/Dockerfile b/backend/pms/Dockerfile index 5fce126..33ab916 100644 --- a/backend/pms/Dockerfile +++ b/backend/pms/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:21-ea-slim +FROM openjdk:17-jdk-alpine WORKDIR /app diff --git a/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java b/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java index 7832ce1..3f418c5 100644 --- a/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java +++ b/backend/pms/src/main/java/com/mini/pms/restcontroller/MemberRestController.java @@ -17,6 +17,7 @@ import java.security.Principal; +import java.util.List; @CrossOrigin(origins = "http://localhost:3000") @RestController diff --git a/frontend/src/pages/Favorite.js b/frontend/src/pages/Favorite.js index 7ba9f50..ba97031 100644 --- a/frontend/src/pages/Favorite.js +++ b/frontend/src/pages/Favorite.js @@ -15,7 +15,7 @@ const Favorite = () => { {data.map((property) => { return ( - + ) })}