From ec9dfab500b5733f637dfffe78449143b15dd4ff Mon Sep 17 00:00:00 2001 From: kshitijrajsharma Date: Thu, 30 May 2024 10:42:35 +0000 Subject: [PATCH] Only push frontend once new release is made to production , also publish release images --- .github/workflows/backend_build.yml | 13 +++-- .github/workflows/docker_publish_image.yml | 8 +-- .github/workflows/frontend_build_push.yml | 59 +++++++++++----------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/.github/workflows/backend_build.yml b/.github/workflows/backend_build.yml index 7d53f39b..7983b9a6 100644 --- a/.github/workflows/backend_build.yml +++ b/.github/workflows/backend_build.yml @@ -3,16 +3,15 @@ on: push: branches: - master - - fix/build paths: - - 'backend/**' - - '.github/workflows/backend_build.yml' + - "backend/**" + - ".github/workflows/backend_build.yml" pull_request: branches: - master paths: - - 'backend/**' - - '.github/workflows/backend_build.yml' + - "backend/**" + - ".github/workflows/backend_build.yml" jobs: Build_on_ubuntu: @@ -111,7 +110,7 @@ jobs: pip install numpy pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="-I/usr/include/gdal" - - name : Check Opencv version + - name: Check Opencv version run: | pip freeze | grep opencv pip install opencv-python-headless==4.7.0.68 @@ -121,7 +120,7 @@ jobs: TESTING_TOKEN: ${{ secrets.TESTING_TOKEN }} run: | cd backend/ - + export TESTING_TOKEN=$TESTING_TOKEN python manage.py makemigrations diff --git a/.github/workflows/docker_publish_image.yml b/.github/workflows/docker_publish_image.yml index 2bdb097a..3bf592da 100644 --- a/.github/workflows/docker_publish_image.yml +++ b/.github/workflows/docker_publish_image.yml @@ -5,9 +5,11 @@ on: branches: - master paths-ignore: - - '.github/workflows/backend_build.yml' - - '.github/workflows/frontend_build.yml' - - '.github/workflows/frontend_build_push.yml' + - ".github/workflows/backend_build.yml" + - ".github/workflows/frontend_build.yml" + - ".github/workflows/frontend_build_push.yml" + release: + types: [released] env: REGISTRY: ghcr.io diff --git a/.github/workflows/frontend_build_push.yml b/.github/workflows/frontend_build_push.yml index d54b03e5..4bd108c5 100644 --- a/.github/workflows/frontend_build_push.yml +++ b/.github/workflows/frontend_build_push.yml @@ -1,11 +1,11 @@ name: Frontend Build and upload to S3 on: - push: - branches: [ master ] + release: + types: [released] paths: - - 'frontend/**' - - '.github/workflows/frontend_build_push.yml' + - "frontend/**" + - ".github/workflows/frontend_build_push.yml" permissions: id-token: write @@ -13,7 +13,6 @@ permissions: jobs: build_and_upload: - runs-on: ubuntu-latest environment: Production env: @@ -21,30 +20,30 @@ jobs: strategy: matrix: - node-version: [ 16.14.2 ] + node-version: [16.14.2] steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - - name: Install dependencies - run: cd frontend/ && npm install --legacy-peer-deps - - - name: Build frontend - run: cd frontend/ && npm run build - env: - REACT_APP_API_BASE: ${{ vars.REACT_APP_API_BASE }} - REACT_APP_PREDICTOR_API_BASE: ${{ vars.REACT_APP_PREDICTOR_API_BASE }} - REACT_APP_ENV: Dev - - - name: Authenticate to AWS - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: us-east-1 - role-to-assume: ${{ secrets.AWS_OIDC_ROLE }} - role-session-name: fAIrGithub - - - name: Upload to S3 - run: cd frontend/build && aws s3 sync . s3://${{ vars.FRONTEND_BUCKET }}/ + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: cd frontend/ && npm install --legacy-peer-deps + + - name: Build frontend + run: cd frontend/ && npm run build + env: + REACT_APP_API_BASE: ${{ vars.REACT_APP_API_BASE }} + REACT_APP_PREDICTOR_API_BASE: ${{ vars.REACT_APP_PREDICTOR_API_BASE }} + REACT_APP_ENV: Dev + + - name: Authenticate to AWS + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: us-east-1 + role-to-assume: ${{ secrets.AWS_OIDC_ROLE }} + role-session-name: fAIrGithub + + - name: Upload to S3 + run: cd frontend/build && aws s3 sync . s3://${{ vars.FRONTEND_BUCKET }}/