From 33aae1ab71b709a401d80fd3b9874d6237eb47ca Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 12:34:37 +0200 Subject: [PATCH 01/25] new development.yml --- .github/workflows/deploy-app.yml | 2 - .github/workflows/development.yml | 76 +++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/development.yml diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index aa4cb34..5971e72 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -15,7 +15,6 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - healthcheck: false branch: 'main' appdir: 'backend' procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod' @@ -30,6 +29,5 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_FRONTEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - healthcheck: false branch: 'main' appdir: 'frontend' diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml new file mode 100644 index 0000000..cbde1e2 --- /dev/null +++ b/.github/workflows/development.yml @@ -0,0 +1,76 @@ +name: Development +run-name: "Run ${{github.run_id}}, triggered by ${{github.actor}}" + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +permissions: + contents: read + +jobs: + build-backend: + name: Build backend + runs-on: ubuntu-latest + defaults: + run: + working-directory: backend + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 for backend + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + + - name: setup Gradle + uses: gradle/actions/setup-gradle@v3 + with: + generate-job-summary: true + add-job-summary-as-pr-comment: on-failure + cache-disabled: true + - name: Set execute permissions for backend gradlew + run: chmod +x gradlew + + - name: Build backend and run tests with Gradle Wrapper + run: ./gradlew build + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: backend + file: backend/build/reports/jacoco/test/html/jacocoTestReport.xml + + backend-test: + name: Test backend + runs-on: ubuntu-latest + needs: build-backend + defaults: + run: + working-directory: backend + steps: + - uses: actions/checkout@v4 + + - name: Run tests with Gradle Wrapper + run: ./gradlew jacocoTestReport + + backend-coverage: + name: Backend coverage + runs-on: ubuntu-latest + needs: backend-test + defaults: + run: + working-directory: backend + steps: + - uses: actions/checkout@v4 + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: backend + file: backend/build/reports/jacoco/test/html/jacocoTestReport.xml From be1edded85014ea93275cfccda5fb7ce762716d1 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 12:43:40 +0200 Subject: [PATCH 02/25] new development.yml --- .github/workflows/development.yml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index cbde1e2..52d5670 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -27,23 +27,10 @@ jobs: distribution: temurin - name: setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - generate-job-summary: true - add-job-summary-as-pr-comment: on-failure - cache-disabled: true - - name: Set execute permissions for backend gradlew - run: chmod +x gradlew - - - name: Build backend and run tests with Gradle Wrapper - run: ./gradlew build + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: backend - file: backend/build/reports/jacoco/test/html/jacocoTestReport.xml + - name: Build backend with Gradle Wrapper + run: ./gradlew build -x test backend-test: name: Test backend From 915a4b5878a9feec969fd7252c98ef1b15d2d77e Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 12:50:46 +0200 Subject: [PATCH 03/25] changed gradlew chmod --- backend/gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 backend/gradlew diff --git a/backend/gradlew b/backend/gradlew old mode 100644 new mode 100755 From b77c444f63627321c2591355d492e5b062197ee6 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 12:55:30 +0200 Subject: [PATCH 04/25] changed gradlew chmod --- .github/workflows/build-backend.yml | 2 -- .github/workflows/development.yml | 11 +++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-backend.yml b/.github/workflows/build-backend.yml index b3fabbf..da5a35b 100644 --- a/.github/workflows/build-backend.yml +++ b/.github/workflows/build-backend.yml @@ -30,8 +30,6 @@ jobs: generate-job-summary: true add-job-summary-as-pr-comment: on-failure cache-disabled: true - - name: Set execute permissions for backend gradlew - run: chmod +x gradlew - name: Build backend and run tests with Gradle Wrapper run: ./gradlew build diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 52d5670..f4bf346 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -32,6 +32,12 @@ jobs: - name: Build backend with Gradle Wrapper run: ./gradlew build -x test + - name: Upload build artifacts + uses: actions/upload-artifact@v2 + with: + name: backend-artifacts + path: backend/build + backend-test: name: Test backend runs-on: ubuntu-latest @@ -42,6 +48,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Download build artifacts + uses: actions/download-artifact@v2 + with: + name: backend-artifacts + - name: Run tests with Gradle Wrapper run: ./gradlew jacocoTestReport From 6ef91bf42990ab11d2209380d595db88b576f6b1 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 13:03:23 +0200 Subject: [PATCH 05/25] changed gradlew chmod --- .github/workflows/development.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index f4bf346..af94884 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -32,11 +32,12 @@ jobs: - name: Build backend with Gradle Wrapper run: ./gradlew build -x test - - name: Upload build artifacts - uses: actions/upload-artifact@v2 + - name: Cache Gradle dependencies + uses: actions/cache@v2 with: - name: backend-artifacts - path: backend/build + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- backend-test: name: Test backend @@ -48,11 +49,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Download build artifacts - uses: actions/download-artifact@v2 - with: - name: backend-artifacts - - name: Run tests with Gradle Wrapper run: ./gradlew jacocoTestReport From 301b229726358c1008c1d1244c4856e0a3bdd9ff Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 13:07:59 +0200 Subject: [PATCH 06/25] cache gradle --- .github/workflows/development.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index af94884..49dc7dd 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -25,20 +25,14 @@ jobs: with: java-version: 17 distribution: temurin - - - name: setup Gradle - uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 + cache: gradle + cache-dependency-path: | + backend/*.gradle* + backend/**/gradle-wrapper.properties - name: Build backend with Gradle Wrapper run: ./gradlew build -x test - - name: Cache Gradle dependencies - uses: actions/cache@v2 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: ${{ runner.os }}-gradle- - backend-test: name: Test backend runs-on: ubuntu-latest From 0caaa7cf9be2ec1c9012b57609693b5a4b2cc340 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 13:25:07 +0200 Subject: [PATCH 07/25] changed development.yml --- .github/workflows/development.yml | 39 +++++++++++-------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 49dc7dd..9105623 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -25,37 +25,24 @@ jobs: with: java-version: 17 distribution: temurin - cache: gradle - cache-dependency-path: | - backend/*.gradle* - backend/**/gradle-wrapper.properties - - name: Build backend with Gradle Wrapper + - name: Cache Gradle packages + id: gradle-cache + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Build backend run: ./gradlew build -x test - backend-test: - name: Test backend - runs-on: ubuntu-latest - needs: build-backend - defaults: - run: - working-directory: backend - steps: - - uses: actions/checkout@v4 - - - name: Run tests with Gradle Wrapper + - name: Run tests run: ./gradlew jacocoTestReport - backend-coverage: - name: Backend coverage - runs-on: ubuntu-latest - needs: backend-test - defaults: - run: - working-directory: backend - steps: - - uses: actions/checkout@v4 - - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 with: From 51264758990bf94039f154116412447016c0de9f Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 19:48:48 +0200 Subject: [PATCH 08/25] changed build-frontend.yml and build-backend.yml --- .github/workflows/build-backend.yml | 43 +++++++--------- .github/workflows/build-frontend.yml | 11 ++-- .github/workflows/deploy-app.yml | 5 +- .github/workflows/development.yml | 51 ------------------- .../src/main/resources/application-prod.yml | 2 +- backend/src/main/resources/application.yml | 2 +- 6 files changed, 29 insertions(+), 85 deletions(-) delete mode 100644 .github/workflows/development.yml diff --git a/.github/workflows/build-backend.yml b/.github/workflows/build-backend.yml index da5a35b..fb121b1 100644 --- a/.github/workflows/build-backend.yml +++ b/.github/workflows/build-backend.yml @@ -3,9 +3,9 @@ run-name: "Run ${{github.run_id}}, triggered by ${{github.actor}}" on: push: - branches: ["main"] + branches: [ "main" ] pull_request: - branches: ["main"] + branches: [ "main" ] jobs: backend: @@ -16,27 +16,22 @@ jobs: run: working-directory: backend steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up JDK 17 for backend - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: temurin + - name: Build and test backend + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + cache-dependency-path: | + backend/*.gradle* + backend/**/gradle-wrapper.properties + - run: ./gradlew build --no-daemon - - name: setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - generate-job-summary: true - add-job-summary-as-pr-comment: on-failure - cache-disabled: true - - - name: Build backend and run tests with Gradle Wrapper - run: ./gradlew build - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: backend - file: backend/build/reports/jacoco/test/html/jacocoTestReport.xml + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: backend + file: backend/build/reports/jacoco/test/html/jacocoTestReport.xml diff --git a/.github/workflows/build-frontend.yml b/.github/workflows/build-frontend.yml index 5488e81..b83cf82 100644 --- a/.github/workflows/build-frontend.yml +++ b/.github/workflows/build-frontend.yml @@ -3,9 +3,9 @@ run-name: "Run ${{github.run_id}}, triggered by ${{github.actor}}" on: push: - branches: ["main"] + branches: [ "main" ] pull_request: - branches: ["main"] + branches: [ "main" ] jobs: build: @@ -17,14 +17,13 @@ jobs: working-directory: frontend steps: - uses: actions/checkout@v3 - - name: Use Node.js 20.x + + - name: Install dependencies uses: actions/setup-node@v3 with: - node-version: 20.x + node-version: 20 cache: 'npm' cache-dependency-path: frontend/package-lock.json - - - name: Install dependencies run: npm install - name: Build diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 5971e72..bf31b1a 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -3,6 +3,9 @@ run-name: "Run ${{github.run_id}}, triggered by ${{github.actor}}" on: workflow_dispatch: + pull_request: + branches: + - main jobs: deploy-backend: @@ -15,7 +18,6 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - branch: 'main' appdir: 'backend' procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod' @@ -29,5 +31,4 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_FRONTEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - branch: 'main' appdir: 'frontend' diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml deleted file mode 100644 index 9105623..0000000 --- a/.github/workflows/development.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Development -run-name: "Run ${{github.run_id}}, triggered by ${{github.actor}}" - -on: - push: - branches: ["main"] - pull_request: - branches: ["main"] - -permissions: - contents: read - -jobs: - build-backend: - name: Build backend - runs-on: ubuntu-latest - defaults: - run: - working-directory: backend - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 17 for backend - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: temurin - - - name: Cache Gradle packages - id: gradle-cache - uses: actions/cache@v4 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Build backend - run: ./gradlew build -x test - - - name: Run tests - run: ./gradlew jacocoTestReport - - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4.0.1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - flags: backend - file: backend/build/reports/jacoco/test/html/jacocoTestReport.xml diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml index da7c9d6..8871d5e 100644 --- a/backend/src/main/resources/application-prod.yml +++ b/backend/src/main/resources/application-prod.yml @@ -31,6 +31,6 @@ spring: password: ${SECURITY_PASSWORD} jwt: secure: true - sameSite: "none" + sameSite: "Strict" duration: 86400000 # 1 day secret: ${JWT_SECRET} diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 45cda93..42f967a 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -21,6 +21,6 @@ spring: default_schema: public jwt: secure: true - sameSite: "none" + sameSite: "Strict" duration: 86400000 # 1 day secret: "7A25432A462D4A614E645267556B58703272357538782F413F4428472B4B6250" # random string in base64, should be changed in production From bb1efaa434e229df107ac91f477900ee9e6fd161 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 19:56:20 +0200 Subject: [PATCH 09/25] changed application-prod.yml and application.yml --- .github/workflows/deploy-app.yml | 1 - backend/src/main/resources/application-prod.yml | 2 +- backend/src/main/resources/application.yml | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index bf31b1a..6c59667 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -6,7 +6,6 @@ on: pull_request: branches: - main - jobs: deploy-backend: runs-on: ubuntu-latest diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml index 8871d5e..df21e9c 100644 --- a/backend/src/main/resources/application-prod.yml +++ b/backend/src/main/resources/application-prod.yml @@ -31,6 +31,6 @@ spring: password: ${SECURITY_PASSWORD} jwt: secure: true - sameSite: "Strict" + sameSite: "Lax" duration: 86400000 # 1 day secret: ${JWT_SECRET} diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 42f967a..b2a8f32 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -21,6 +21,6 @@ spring: default_schema: public jwt: secure: true - sameSite: "Strict" + sameSite: "Lax" duration: 86400000 # 1 day secret: "7A25432A462D4A614E645267556B58703272357538782F413F4428472B4B6250" # random string in base64, should be changed in production From 3c0a2c6b57a9335a08004888cedd4e0252422fe9 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 21:33:01 +0200 Subject: [PATCH 10/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 2 +- .../src/app/shared/http/interceptor/http-error.interceptor.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 6c59667..023a888 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -28,6 +28,6 @@ jobs: uses: akhileshns/heroku-deploy@v3.13.15 with: heroku_api_key: ${{secrets.HEROKU_API_KEY}} - heroku_app_name: ${{ secrets.HEROKU_FRONTEND_NAME }} + heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} appdir: 'frontend' diff --git a/frontend/src/app/shared/http/interceptor/http-error.interceptor.ts b/frontend/src/app/shared/http/interceptor/http-error.interceptor.ts index c31b9d6..cef371b 100644 --- a/frontend/src/app/shared/http/interceptor/http-error.interceptor.ts +++ b/frontend/src/app/shared/http/interceptor/http-error.interceptor.ts @@ -3,6 +3,7 @@ import {inject, Injectable} from "@angular/core"; import {catchError, Observable, throwError} from "rxjs"; import {NotificationService} from "../../notification/service/notification.service"; import {Router} from "@angular/router"; +import {AuthService} from "../../../auth/service/auth.service"; @Injectable() export class HttpErrorInterceptor implements HttpInterceptor { @@ -14,6 +15,7 @@ export class HttpErrorInterceptor implements HttpInterceptor { catchError((error: HttpErrorResponse) => { if (error.status == 401) { this.notificationService.errorNotification("You do not have access to this feature, please login") + sessionStorage.removeItem('auth') this.router.navigate(['/signIn']) } return throwError(error) From 4e902ff70ad402567f516110e54d0f8cf55e8541 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 21:34:33 +0200 Subject: [PATCH 11/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 023a888..8bf7aba 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -22,6 +22,7 @@ jobs: deploy-frontend: runs-on: ubuntu-latest + needs: deploy-backend steps: - uses: actions/checkout@v4 - name: Deploy backend to Heroku From e69a851918d12b6657156ddf08b1b9639fdbe5b4 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 21:37:45 +0200 Subject: [PATCH 12/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 8bf7aba..2fdc050 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -17,18 +17,5 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - appdir: 'backend' procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod' - deploy-frontend: - runs-on: ubuntu-latest - needs: deploy-backend - steps: - - uses: actions/checkout@v4 - - name: Deploy backend to Heroku - uses: akhileshns/heroku-deploy@v3.13.15 - with: - heroku_api_key: ${{secrets.HEROKU_API_KEY}} - heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} - heroku_email: ${{ secrets.HEROKU_EMAIL }} - appdir: 'frontend' From 21ae3c8fd89fd96cf375ad617b2856bc7a16a12d Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 21:48:07 +0200 Subject: [PATCH 13/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 2fdc050..b9285a8 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -10,12 +10,28 @@ jobs: deploy-backend: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Deploy backend to Heroku + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Build Backend + working-directory: backend + run: | + ./gradlew build + cp build/libs/backend-1.0.0.jar ../backend.jar + + - name: Build Frontend + working-directory: frontend + run: | + npm install + npm run build + + - name: Deploy to Heroku uses: akhileshns/heroku-deploy@v3.13.15 with: heroku_api_key: ${{secrets.HEROKU_API_KEY}} - heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} + heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod' - + appdir: '.' # Deploy the root directory, which contains both backend and frontend + procfile: | + web: java $JAVA_OPTS -Dserver.port=$PORT -jar backend.jar --spring.profiles.active=prod + build: cd frontend && npm start From 278d0c589401b501c2a25c50952cb07da5e8cb2a Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 21:50:21 +0200 Subject: [PATCH 14/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index b9285a8..117615d 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -13,13 +13,26 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - - name: Build Backend + - name: Build backend working-directory: backend + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + cache-dependency-path: | + backend/*.gradle* + backend/**/gradle-wrapper.properties run: | - ./gradlew build + ./gradlew build --no-daemon cp build/libs/backend-1.0.0.jar ../backend.jar - - name: Build Frontend + - name: Build frontend + uses: actions/setup-node@v3 + with: + node-version: 20 + cache: 'npm' + cache-dependency-path: frontend/package-lock.json working-directory: frontend run: | npm install From 0427717b51888a84e017b5c746e8d56878d1069c Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 22:03:21 +0200 Subject: [PATCH 15/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 117615d..efff8d4 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -14,7 +14,6 @@ jobs: uses: actions/checkout@v4 - name: Build backend - working-directory: backend uses: actions/setup-java@v4 with: distribution: 'temurin' @@ -23,6 +22,9 @@ jobs: cache-dependency-path: | backend/*.gradle* backend/**/gradle-wrapper.properties + + - name: Build backend + working-directory: backend run: | ./gradlew build --no-daemon cp build/libs/backend-1.0.0.jar ../backend.jar @@ -33,6 +35,8 @@ jobs: node-version: 20 cache: 'npm' cache-dependency-path: frontend/package-lock.json + + - name: Install dependencies working-directory: frontend run: | npm install From 4f18361b1538814b39a66d457352fd9733e4e05a Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 22:12:46 +0200 Subject: [PATCH 16/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index efff8d4..98e3085 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -48,7 +48,6 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - appdir: '.' # Deploy the root directory, which contains both backend and frontend procfile: | web: java $JAVA_OPTS -Dserver.port=$PORT -jar backend.jar --spring.profiles.active=prod build: cd frontend && npm start From 4eb17e3a4b831a918a6fcc15cffa72acf2fe3f00 Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 22:26:33 +0200 Subject: [PATCH 17/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 53 ++++++++++---------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 98e3085..8801dc9 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -4,50 +4,29 @@ run-name: "Run ${{github.run_id}}, triggered by ${{github.actor}}" on: workflow_dispatch: pull_request: - branches: - - main + branches: [ "main" ] jobs: deploy-backend: runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Build backend - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' - cache: 'gradle' - cache-dependency-path: | - backend/*.gradle* - backend/**/gradle-wrapper.properties - - - name: Build backend - working-directory: backend - run: | - ./gradlew build --no-daemon - cp build/libs/backend-1.0.0.jar ../backend.jar - - - name: Build frontend - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - name: Deploy backend to Heroku + uses: akhileshns/heroku-deploy@v3.13.15 with: - node-version: 20 - cache: 'npm' - cache-dependency-path: frontend/package-lock.json - - - name: Install dependencies - working-directory: frontend - run: | - npm install - npm run build + heroku_api_key: ${{secrets.HEROKU_API_KEY}} + heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} + heroku_email: ${{ secrets.HEROKU_EMAIL }} + branch: 'main' + procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod' - - name: Deploy to Heroku + deploy-frontend: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Deploy backend to Heroku uses: akhileshns/heroku-deploy@v3.13.15 with: heroku_api_key: ${{secrets.HEROKU_API_KEY}} - heroku_app_name: ${{ secrets.HEROKU_APP_NAME }} + heroku_app_name: ${{ secrets.HEROKU_FRONTEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - procfile: | - web: java $JAVA_OPTS -Dserver.port=$PORT -jar backend.jar --spring.profiles.active=prod - build: cd frontend && npm start + appdir: 'frontend' From a2c7dc84da6f161e881458314c1e8b2cca8f0c0d Mon Sep 17 00:00:00 2001 From: StepanMoc Date: Thu, 9 May 2024 22:27:26 +0200 Subject: [PATCH 18/25] changed deploy-app.yml --- .github/workflows/deploy-app.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 8801dc9..cf1a32f 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -16,7 +16,7 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} - branch: 'main' + appdir: 'backend' procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod' deploy-frontend: From 367efdad265c62a6e0ae546f81cc14a1c684e042 Mon Sep 17 00:00:00 2001 From: "stepan.moc" Date: Fri, 10 May 2024 21:47:55 +0200 Subject: [PATCH 19/25] Update TokenFilter.kt --- .../kotlin/com/tul/backend/auth/base/service/TokenFilter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt b/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt index 05ca900..6b058be 100644 --- a/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt +++ b/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt @@ -5,6 +5,8 @@ import jakarta.servlet.http.HttpServletRequest import org.springframework.stereotype.Component import org.springframework.web.util.WebUtils +private val log = KotlinLogging.logger {} + @Component class TokenFilter( private val accessTokenService: AccessTokenService @@ -12,7 +14,7 @@ class TokenFilter( fun validateRequest(request: HttpServletRequest): AccessTokenClaims? { val token = WebUtils.getCookie(request, accessTokenService.COOKIE_NAME) - + log.error { "Token: $token" } if (token != null) { return accessTokenService.extractClaims(token.value) } From 9c1ac9cc5baf12c631509c41f2dc828cbd852ee2 Mon Sep 17 00:00:00 2001 From: "stepan.moc" Date: Fri, 10 May 2024 21:48:48 +0200 Subject: [PATCH 20/25] Update JwtAuthenticationFilter.kt --- .../tul/backend/auth/base/config/JwtAuthenticationFilter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/kotlin/com/tul/backend/auth/base/config/JwtAuthenticationFilter.kt b/backend/src/main/kotlin/com/tul/backend/auth/base/config/JwtAuthenticationFilter.kt index 63af61f..e490c50 100644 --- a/backend/src/main/kotlin/com/tul/backend/auth/base/config/JwtAuthenticationFilter.kt +++ b/backend/src/main/kotlin/com/tul/backend/auth/base/config/JwtAuthenticationFilter.kt @@ -8,7 +8,9 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.core.context.SecurityContextHolder import org.springframework.stereotype.Component import org.springframework.web.filter.OncePerRequestFilter +import io.github.oshai.kotlinlogging.KotlinLogging +private val log = KotlinLogging.logger {} @Component class JwtAuthenticationFilter( @@ -21,7 +23,7 @@ class JwtAuthenticationFilter( filterChain: FilterChain ) { val validClaims = tokenFilter.validateRequest(request) - + log.error { "Claims: $validClaims" } if (validClaims != null) { val authToken = UsernamePasswordAuthenticationToken(validClaims, null, listOf(validClaims.authUserRole)) SecurityContextHolder.getContext().authentication = authToken From 2ca5fb7431de5809d5dd29dd280f138c8e053482 Mon Sep 17 00:00:00 2001 From: "stepan.moc" Date: Fri, 10 May 2024 21:48:59 +0200 Subject: [PATCH 21/25] Update JwtService.kt --- .../kotlin/com/tul/backend/auth/base/service/JwtService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt b/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt index 8b340a3..7a3952c 100644 --- a/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt +++ b/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt @@ -5,7 +5,7 @@ import io.jsonwebtoken.Claims import io.jsonwebtoken.Jwts import io.jsonwebtoken.io.Decoders import io.jsonwebtoken.security.Keys - +import io.github.oshai.kotlinlogging.KotlinLogging class JwtService( secret: String @@ -37,4 +37,4 @@ class JwtService( null } } -} \ No newline at end of file +} From cb4f3a24833b085d63ea4ecd0a06343a17748b50 Mon Sep 17 00:00:00 2001 From: "stepan.moc" Date: Fri, 10 May 2024 21:49:07 +0200 Subject: [PATCH 22/25] Update JwtService.kt --- .../main/kotlin/com/tul/backend/auth/base/service/JwtService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt b/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt index 7a3952c..e1ff32b 100644 --- a/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt +++ b/backend/src/main/kotlin/com/tul/backend/auth/base/service/JwtService.kt @@ -5,7 +5,6 @@ import io.jsonwebtoken.Claims import io.jsonwebtoken.Jwts import io.jsonwebtoken.io.Decoders import io.jsonwebtoken.security.Keys -import io.github.oshai.kotlinlogging.KotlinLogging class JwtService( secret: String From 7d3e7bc373ad08e222796c64c7e38edb22327010 Mon Sep 17 00:00:00 2001 From: "stepan.moc" Date: Fri, 10 May 2024 21:49:15 +0200 Subject: [PATCH 23/25] Update TokenFilter.kt --- .../main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt b/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt index 6b058be..055dd74 100644 --- a/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt +++ b/backend/src/main/kotlin/com/tul/backend/auth/base/service/TokenFilter.kt @@ -4,6 +4,7 @@ import com.tul.backend.auth.base.dto.AccessTokenClaims import jakarta.servlet.http.HttpServletRequest import org.springframework.stereotype.Component import org.springframework.web.util.WebUtils +import io.github.oshai.kotlinlogging.KotlinLogging private val log = KotlinLogging.logger {} From 2fa7ab083fdf9321489591006e71edfd192fd732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Moc?= Date: Thu, 16 May 2024 09:31:52 +0200 Subject: [PATCH 24/25] changed baseUrl for FE enviroment.prod --- frontend/src/environments/environment.prod.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/environments/environment.prod.ts b/frontend/src/environments/environment.prod.ts index c6774a6..c84b8a0 100644 --- a/frontend/src/environments/environment.prod.ts +++ b/frontend/src/environments/environment.prod.ts @@ -1,5 +1,5 @@ export const environment = { - baseUrl: 'https://moc-backend-weather-app-d8c5764193db.herokuapp.com/', + baseUrl: 'http://www.weather-app-backend.moc-backend.cz/', production: true, version: '1.0.0' }; From f6637f4a61811d86cf9d1ad8b2662c6f65f53ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Moc?= Date: Thu, 16 May 2024 09:37:53 +0200 Subject: [PATCH 25/25] changed deploy-app.yml branch --- .github/workflows/deploy-app.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index cf1a32f..5971e72 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -3,8 +3,7 @@ run-name: "Run ${{github.run_id}}, triggered by ${{github.actor}}" on: workflow_dispatch: - pull_request: - branches: [ "main" ] + jobs: deploy-backend: runs-on: ubuntu-latest @@ -16,6 +15,7 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_BACKEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} + branch: 'main' appdir: 'backend' procfile: 'web: java $JAVA_OPTS -Dserver.port=$PORT -jar build/libs/backend-1.0.0.jar --spring.profiles.active=prod' @@ -29,4 +29,5 @@ jobs: heroku_api_key: ${{secrets.HEROKU_API_KEY}} heroku_app_name: ${{ secrets.HEROKU_FRONTEND_NAME }} heroku_email: ${{ secrets.HEROKU_EMAIL }} + branch: 'main' appdir: 'frontend'