From 2cad64a89310b47fc2fcf2f5e64c1d5f0dc4dc97 Mon Sep 17 00:00:00 2001 From: Abhishek SAINI Date: Thu, 12 Sep 2024 13:41:03 +0200 Subject: [PATCH] Update ci.yml --- .github/workflows/ci.yml | 132 ++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e7966f..3a6092d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,7 +117,7 @@ jobs: continue-on-error: true # Step: Run unit tests - test: + test-frontend: needs: [lint, format, security-audit] runs-on: ubuntu-latest steps: @@ -138,67 +138,71 @@ jobs: env: CI: true # Ensures Vitest runs in Continuous Integration mode + # Step: Build the Frontend project + build-frontend: + needs: test-frontend + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + # Restore Frontend Node.js Modules cache + - name: Restore Frontend Node.js Modules Cache + uses: actions/cache@v3 + with: + path: frontend/node_modules + key: ${{ runner.os }}-frontend-${{ hashFiles('frontend/package-lock.json') }} + + - name: Build Frontend for Production + run: npm run build:prod + working-directory: ./frontend + env: + NODE_ENV: production + APP_API_BASE_URL: ${{ vars.APP_API_BASE_URL }} + APP_LOGGING: ${{ vars.APP_LOGGING }} + APP_PORT: ${{ vars.FRONTEND_APP_PORT }} + + - name: Save Frontend Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: frontend-build + path: frontend/dist - # # Step: Build the project - # build: - # needs: test - # runs-on: ubuntu-latest - # steps: - # - name: Checkout Code - # uses: actions/checkout@v3 - - # - name: Setup Node.js - # uses: ./.github/workflows/setup-node.yml - - # # Restore Server Node.js Modules cache - # - name: Restore Server Node.js Modules Cache - # uses: actions/cache@v3 - # with: - # path: server/node_modules - # key: ${{ runner.os }}-server-node-${{ hashFiles('server/package-lock.json') }} - - # - name: Build Server for Production - # run: npm run build - # working-directory: ./server - # env: - # NODE_ENV: production - # PORT: ${{ vars.API_PORT }} - # MONGO_URI: ${{ vars.MONGO_URI }} - # MONGO_DB_HOST: ${{ vars.MONGO_DB_HOST }} - # TOKEN_ISSUER: ${{ vars.TOKEN_ISSUER}} - # TOKEN_AUDIENCE: ${{ vars.TOKEN_AUDIENCE}} - # CORS_URL: ${{ vars.CORS_URL}} - # FRONTEND_RESET_URL: ${{ vars.FRONTEND_RESET_URL}} - # API_VERSION: ${{ vars.API_VERSION}} - # ACCESS_TOKEN_SECRET_KEY: ${{ secrets.ACCESS_TOKEN_SECRET_KEY}} - # MAILTRAP_TESTING_PASSWORD: ${{ secrets.MAILTRAP_TESTING_PASSWORD}} - # MAILTRAP_TESTING_USERNAME: ${{ secrets.MAILTRAP_TESTING_USERNAME}} - # REFRESH_TOKEN_SECRET_KEY: ${{ secrets.REFRESH_TOKEN_SECRET_KEY}} - - # # Restore Frontend Node.js Modules cache - # - name: Restore Frontend Node.js Modules Cache - # uses: actions/cache@v3 - # with: - # path: frontend/node_modules - # key: ${{ runner.os }}-frontend-node-${{ hashFiles('frontend/package-lock.json') }} - - # - name: Build Frontend for Production - # run: npm run build:prod - # working-directory: ./frontend - # env: - # NODE_ENV: production - # APP_API_BASE_URL: ${{ vars.APP_API_BASE_URL }} - # APP_LOGGING: ${{ vars.APP_LOGGING }} - # APP_PORT: ${{ vars.FRONTEND_APP_PORT }} - - # - name: Save Server Build Artifacts - # uses: actions/upload-artifact@v4 - # with: - # name: server-build - # path: server/build - - # - name: Save Frontend Build Artifacts - # uses: actions/upload-artifact@v4 - # with: - # name: frontend-build - # path: frontend/dist + # Step: Build the Server project + build-server: + needs: [lint, format, security-audit] + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + # Restore Server Node.js Modules cache + - name: Restore Server Node.js Modules Cache + uses: actions/cache@v3 + with: + path: server/node_modules + key: ${{ runner.os }}-server-${{ hashFiles('server/package-lock.json') }} + + - name: Build Server for Production + run: npm run build + working-directory: ./server + env: + NODE_ENV: production + PORT: ${{ vars.API_PORT }} + MONGO_URI: ${{ vars.MONGO_URI }} + MONGO_DB_HOST: ${{ vars.MONGO_DB_HOST }} + TOKEN_ISSUER: ${{ vars.TOKEN_ISSUER}} + TOKEN_AUDIENCE: ${{ vars.TOKEN_AUDIENCE}} + CORS_URL: ${{ vars.CORS_URL}} + FRONTEND_RESET_URL: ${{ vars.FRONTEND_RESET_URL}} + API_VERSION: ${{ vars.API_VERSION}} + ACCESS_TOKEN_SECRET_KEY: ${{ secrets.ACCESS_TOKEN_SECRET_KEY}} + MAILTRAP_TESTING_PASSWORD: ${{ secrets.MAILTRAP_TESTING_PASSWORD}} + MAILTRAP_TESTING_USERNAME: ${{ secrets.MAILTRAP_TESTING_USERNAME}} + REFRESH_TOKEN_SECRET_KEY: ${{ secrets.REFRESH_TOKEN_SECRET_KEY}} + + - name: Save Server Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: server-build + path: server/build