From a79d3f6b3831c82a91f1f2f9cafdfef239a40a9c Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 3 Dec 2024 10:52:54 -0700 Subject: [PATCH] test with sha with middleware --- .github/workflows/deploy-dev.yml | 261 ++++++++++++++++--------------- 1 file changed, 135 insertions(+), 126 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 0cd00abf..80eb74c0 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,24 +1,23 @@ name: Build and deploy all of ReportVision's services to a development environment on: - workflow_dispatch: - inputs: - deploy-env: - description: 'The environment to deploy to' - required: true - type: choice - options: - - dev - - demo - ocr-docker-tag: - description: 'This is optional if you would like to deploy an already published OCR-API image' - required: false - ocr-version: - description: 'Create a version for this OCR API image' - required: true - middleware-version: - description: 'Create a version for this middleware API image' - required: true + push: + branches: use-sha-instead-of-version + # workflow_dispatch: + # inputs: + # deploy-env: + # description: 'The environment to deploy to' + # required: true + # type: choice + # options: + # - dev + # - demo + # ocr-docker-tag: + # description: 'This is optional if you would like to deploy an already published OCR-API image' + # required: false + # middleware-docker-tag: + # description: 'This is optional if you would like to deploy an already published Middleware-API image' + # required: false permissions: contents: read @@ -30,33 +29,6 @@ jobs: build-publish-middleware: name: Build and Publish middleware runs-on: ubuntu-latest - outputs: - docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} - steps: - - uses: actions/checkout@v4 - - name: Lowercase the repo name - run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - - name: Check if image exists - id: image_check - run: | - echo "docker_inspect=$( - docker manifest inspect ghcr.io/${{ env.REPO }}-middleware-api:${{ inputs.middleware-version }} > /dev/null ; echo $? - )" >> $GITHUB_OUTPUT - - name: Build and Push the middleware - if: ${{ steps.image_check.outputs.docker_inspect == 1 }} - uses: ./.github/actions/build-publish-api - with: - docker-registry: ghcr.io - docker-pw: ${{ secrets.GITHUB_TOKEN }} - docker-username: ${{ github.actor }} - docker-tag: ${{ inputs.middleware-version }} - dockerfile-path: ./backend/Dockerfile - docker-context-path: ./backend/ - api-name: middleware-api - - build-publish-ocr: - name: Build and Publish OCR - runs-on: ubuntu-latest outputs: docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} docker_tag: ${{ steps.set_tag.outputs.docker_tag }} @@ -64,11 +36,11 @@ jobs: - uses: actions/checkout@v4 - name: Lowercase the repo name run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - - name: Set OCR Docker tag + - name: Set Middleware Docker tag shell: bash id: set_tag run: | - USER_INPUT="${{ github.event.inputs.ocr-docker-tag }}" + USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty echo ${USER_INPUT:-"${{ github.sha }}"} @@ -77,9 +49,9 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:${{ steps.set_tag.outputs.docker_tag }} > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-middleware-api:${{ steps.set_tag.outputs.docker_tag }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - - name: Build and Push the OCR + - name: Build and Push the middleware if: ${{ steps.image_check.outputs.docker_inspect == 1 }} uses: ./.github/actions/build-publish-api with: @@ -87,50 +59,87 @@ jobs: docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} docker-tag: ${{ steps.set_tag.outputs.docker_tag }} - dockerfile-path: ./OCR/Dockerfile - docker-context-path: ./OCR/ - api-name: ocr-api + dockerfile-path: ./backend/Dockerfile + docker-context-path: ./backend/ + api-name: middleware-api - build-frontend: - name: Build Frontend - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build-frontend - name: Build frontend - with: - api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/ - frontend-tarball: ./frontend.tgz - frontend-path: ./frontend - frontend-build-path: ./frontend/dist/ - node-version: 20 + # build-publish-ocr: + # name: Build and Publish OCR + # runs-on: ubuntu-latest + # outputs: + # docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} + # docker_tag: ${{ steps.set_tag.outputs.docker_tag }} + # steps: + # - uses: actions/checkout@v4 + # - name: Lowercase the repo name + # run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + # - name: Set OCR Docker tag + # shell: bash + # id: set_tag + # run: | + # USER_INPUT="${{ github.event.inputs.ocr-docker-tag }}" + # echo "docker_tag=$( + # #this gives a new sha as default if dispatch input is empty + # echo ${USER_INPUT:-"${{ github.sha }}"} + # )" >> $GITHUB_OUTPUT + # - name: Check if image exists + # id: image_check + # run: | + # echo "docker_inspect=$( + # docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:${{ steps.set_tag.outputs.docker_tag }} > /dev/null ; echo $? + # )" >> $GITHUB_OUTPUT + # - name: Build and Push the OCR + # if: ${{ steps.image_check.outputs.docker_inspect == 1 }} + # uses: ./.github/actions/build-publish-api + # with: + # docker-registry: ghcr.io + # docker-pw: ${{ secrets.GITHUB_TOKEN }} + # docker-username: ${{ github.actor }} + # docker-tag: ${{ steps.set_tag.outputs.docker_tag }} + # dockerfile-path: ./OCR/Dockerfile + # docker-context-path: ./OCR/ + # api-name: ocr-api - az-environment-setup: - name: Setup Azure Environment - runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - steps: - - uses: actions/checkout@v4 - - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - uses: ./.github/actions/tf-setup - name: Setup this environment with Terraform - with: - deploy-env: ${{ inputs.deploy-env }} - azure-resource-group: reportvision-rg-${{ inputs.deploy-env }} - azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} - azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} - azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - app-name: reportvision + # build-frontend: + # name: Build Frontend + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: ./.github/actions/build-frontend + # name: Build frontend + # with: + # api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/ + # frontend-tarball: ./frontend.tgz + # frontend-path: ./frontend + # frontend-build-path: ./frontend/dist/ + # node-version: 20 + + # az-environment-setup: + # name: Setup Azure Environment + # runs-on: ubuntu-latest + # environment: ${{ inputs.deploy-env }} + # steps: + # - uses: actions/checkout@v4 + # - uses: azure/login@v2 + # with: + # client-id: ${{ secrets.AZURE_CLIENT_ID }} + # tenant-id: ${{ secrets.AZURE_TENANT_ID }} + # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + # - uses: ./.github/actions/tf-setup + # name: Setup this environment with Terraform + # with: + # deploy-env: ${{ inputs.deploy-env }} + # azure-resource-group: reportvision-rg-${{ inputs.deploy-env }} + # azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} + # azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} + # azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + # app-name: reportvision deploy-middleware: name: Deploy middleware runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - needs: [build-publish-middleware, az-environment-setup] + environment: dev + needs: [build-publish-middleware] steps: - uses: actions/checkout@v4 - uses: azure/login@v2 @@ -141,46 +150,46 @@ jobs: - name: Deploy middleware-API uses: ./.github/actions/deploy-api with: - deploy-env: ${{ inputs.deploy-env }} - docker-tag: ${{ inputs.middleware-version }} + deploy-env: dev + docker-tag: ${{ needs.build-publish-middleware.outputs.docker_tag }} docker-registry: ghcr.io api-name: middleware-api - deploy-ocr: - name: Deploy OCR - runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - needs: [build-publish-ocr, az-environment-setup] - steps: - - uses: actions/checkout@v4 - - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - name: Deploy OCR-API - uses: ./.github/actions/deploy-api - with: - deploy-env: ${{ inputs.deploy-env }} - docker-tag: ${{ needs.build-publish-ocr.outputs.docker_tag }} - docker-registry: ghcr.io - api-name: ocr-api + # deploy-ocr: + # name: Deploy OCR + # runs-on: ubuntu-latest + # environment: ${{ inputs.deploy-env }} + # needs: [build-publish-ocr, az-environment-setup] + # steps: + # - uses: actions/checkout@v4 + # - uses: azure/login@v2 + # with: + # client-id: ${{ secrets.AZURE_CLIENT_ID }} + # tenant-id: ${{ secrets.AZURE_TENANT_ID }} + # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + # - name: Deploy OCR-API + # uses: ./.github/actions/deploy-api + # with: + # deploy-env: ${{ inputs.deploy-env }} + # docker-tag: ${{ needs.build-publish-ocr.outputs.docker_tag }} + # docker-registry: ghcr.io + # api-name: ocr-api - deploy-frontend: - name: Deploy Frontend - runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - needs: [build-frontend, az-environment-setup] - if: ${{ inputs.deploy-env != 'demo'}} - steps: - - uses: actions/checkout@v4 - - uses: azure/login@v2 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - name: Deploy frontend - uses: ./.github/actions/deploy-frontend - with: - frontend-tarball: frontend.tgz - deploy-env: ${{ inputs.deploy-env }} \ No newline at end of file + # deploy-frontend: + # name: Deploy Frontend + # runs-on: ubuntu-latest + # environment: ${{ inputs.deploy-env }} + # needs: [build-frontend, az-environment-setup] + # if: ${{ inputs.deploy-env != 'demo'}} + # steps: + # - uses: actions/checkout@v4 + # - uses: azure/login@v2 + # with: + # client-id: ${{ secrets.AZURE_CLIENT_ID }} + # tenant-id: ${{ secrets.AZURE_TENANT_ID }} + # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + # - name: Deploy frontend + # uses: ./.github/actions/deploy-frontend + # with: + # frontend-tarball: frontend.tgz + # deploy-env: ${{ inputs.deploy-env }} \ No newline at end of file