From eb631daf2a916b80211cd35acec1e0dd7e3e4519 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 17 Dec 2024 15:34:32 -0700 Subject: [PATCH 1/6] add vars --- .github/actions/tf-setup/action.yml | 10 +++++++++- .github/workflows/deploy-dev.yml | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/actions/tf-setup/action.yml b/.github/actions/tf-setup/action.yml index 2f08432b..f8c3095c 100644 --- a/.github/actions/tf-setup/action.yml +++ b/.github/actions/tf-setup/action.yml @@ -32,11 +32,19 @@ runs: env: RESOURCE_GROUP_NAME: ${{ inputs.azure-resource-group }} NAME: ${{ inputs.app-name }} - SKU_NAME: P3v3 + SKU_NAME: S2 + OBJECT_ID: ${{ inputs.azure-object-id }} + TENANT_ID: ${{ inputs.azure-tenant-id }} + CLIENT_ID: ${{ inputs.azure-client-id }} + SUBSCRIPTION_ID: ${{ inputs.azure-subscription-id }} run: | echo resource_group_name=\""$RESOURCE_GROUP_NAME"\" >> terraform.tfvars echo name=\""$NAME"\" >> terraform.tfvars echo sku_name=\""$SKU_NAME"\" >> terraform.tfvars + echo object_id=\""$OBJECT_ID"\" >> terraform.tfvars + echo tenant_id=\""$TENANT_ID"\" >> terraform.tfvars + echo client_id=\""$CLIENT_ID"\" >> terraform.tfvars + echo subscription_id=\""$SUBSCRIPTION_ID"\" >> terraform.tfvars az config set defaults.group=$RESOURCE_GROUP_NAME - name: Set environment shell: bash diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index ab88e00b..3131f7f0 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -132,7 +132,7 @@ jobs: azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - object-id: ${{ secrets.AZURE_OBJECT_ID }} + azure-object-id: ${{ secrets.AZURE_OBJECT_ID }} app-name: reportvision deploy-middleware: From ecb9f99746e31916b29b52f7c8b5e98fc4b7ba4e Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 17 Dec 2024 16:05:20 -0700 Subject: [PATCH 2/6] test new sha --- .github/workflows/deploy-dev.yml | 62 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 3131f7f0..ce88be79 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,21 +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 - middleware-docker-tag: - description: 'This is optional if you would like to deploy an already published Middleware-API image' - required: false + push: + branches: set-variables-for-db-different + # 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 @@ -38,10 +40,10 @@ jobs: shell: bash id: set_tag run: | - USER_INPUT="${{ github.event.inputs.middleware-docker-tag }}" + USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty - echo ${USER_INPUT:-"${{ github.sha }}"} + echo ${USER_INPUT:-"$(git rev-parse --short HEAD)"} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check @@ -75,10 +77,10 @@ jobs: 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 }}"} + echo ${USER_INPUT:-"$(git rev-parse --short HEAD)"} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check @@ -106,7 +108,7 @@ jobs: - uses: ./.github/actions/build-frontend name: Build frontend with: - api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/ + api-endpoint: https://reportvision-ocr-dev.azurewebsites.net/ frontend-tarball: ./frontend.tgz frontend-path: ./frontend frontend-build-path: ./frontend/dist/ @@ -115,7 +117,7 @@ jobs: az-environment-setup: name: Setup Azure Environment runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} + environment: dev steps: - uses: actions/checkout@v4 - uses: azure/login@v2 @@ -127,8 +129,8 @@ jobs: - 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 }} + deploy-env: dev + azure-resource-group: reportvision-rg-dev azure-client-id: ${{ secrets.AZURE_CLIENT_ID }} azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }} azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} @@ -138,7 +140,7 @@ jobs: deploy-middleware: name: Deploy middleware runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} + environment: dev needs: [build-publish-middleware, az-environment-setup] steps: - uses: actions/checkout@v4 @@ -151,7 +153,7 @@ jobs: - name: Deploy middleware-API uses: ./.github/actions/deploy-api with: - deploy-env: ${{ inputs.deploy-env }} + deploy-env: dev docker-tag: ${{ needs.build-publish-middleware.outputs.docker_tag }} docker-registry: ghcr.io api-name: middleware @@ -159,7 +161,7 @@ jobs: deploy-ocr: name: Deploy OCR runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} + environment: dev needs: [build-publish-ocr, az-environment-setup] steps: - uses: actions/checkout@v4 @@ -172,7 +174,7 @@ jobs: - name: Deploy OCR-API uses: ./.github/actions/deploy-api with: - deploy-env: ${{ inputs.deploy-env }} + deploy-env: dev docker-tag: ${{ needs.build-publish-ocr.outputs.docker_tag }} docker-registry: ghcr.io api-name: ocr @@ -180,9 +182,9 @@ jobs: deploy-frontend: name: Deploy Frontend runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} + environment: dev needs: [build-frontend, az-environment-setup] - if: ${{ inputs.deploy-env != 'demo'}} + if: ${{ 'dev' != 'demo'}} steps: - uses: actions/checkout@v4 - uses: azure/login@v2 @@ -195,4 +197,4 @@ jobs: uses: ./.github/actions/deploy-frontend with: frontend-tarball: frontend.tgz - deploy-env: ${{ inputs.deploy-env }} \ No newline at end of file + deploy-env: dev \ No newline at end of file From 3d9504f28e683cd75d747139c7dbd571df6a2fb0 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 17 Dec 2024 16:06:52 -0700 Subject: [PATCH 3/6] test new sha --- .github/workflows/deploy-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index ce88be79..a5b2514e 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -43,7 +43,7 @@ jobs: USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty - echo ${USER_INPUT:-"$(git rev-parse --short HEAD)"} + echo ${USER_INPUT:-$(git rev-parse --short HEAD)} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check @@ -80,7 +80,7 @@ jobs: USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty - echo ${USER_INPUT:-"$(git rev-parse --short HEAD)"} + echo ${USER_INPUT:-$(git rev-parse --short HEAD)} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check From d72251861e9e0cd0e07edac3a83d514f7f02ecf8 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 17 Dec 2024 16:10:37 -0700 Subject: [PATCH 4/6] test new sha --- .github/workflows/deploy-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index a5b2514e..3bb130c3 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -43,7 +43,7 @@ jobs: USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty - echo ${USER_INPUT:-$(git rev-parse --short HEAD)} + echo ${USER_INPUT:-uuidgen} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check @@ -80,7 +80,7 @@ jobs: USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty - echo ${USER_INPUT:-$(git rev-parse --short HEAD)} + echo ${USER_INPUT:-uuidgen} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check From 417b61087a48aba802e22dfa8d5d4ff7a77d6ba5 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 17 Dec 2024 16:12:30 -0700 Subject: [PATCH 5/6] test new sha --- .github/workflows/deploy-dev.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 3bb130c3..46036196 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -43,7 +43,7 @@ jobs: USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty - echo ${USER_INPUT:-uuidgen} + echo ${USER_INPUT:-$(uuidgen)} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check @@ -80,7 +80,7 @@ jobs: USER_INPUT="" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty - echo ${USER_INPUT:-uuidgen} + echo ${USER_INPUT:-$(uuidgen)} )" >> $GITHUB_OUTPUT - name: Check if image exists id: image_check From 19676d7b3966894478ab09ffc6aa568244595679 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 17 Dec 2024 16:14:49 -0700 Subject: [PATCH 6/6] clean up --- .github/workflows/deploy-dev.yml | 58 +++++++++++++++----------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 46036196..177f32d6 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,23 +1,21 @@ name: Build and deploy all of ReportVision's services to a development environment on: - push: - branches: set-variables-for-db-different - # 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 + 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 @@ -40,7 +38,7 @@ jobs: shell: bash id: set_tag run: | - USER_INPUT="" + USER_INPUT="${{ github.event.inputs.middleware-docker-tag }}" echo "docker_tag=$( #this gives a new sha as default if dispatch input is empty echo ${USER_INPUT:-$(uuidgen)} @@ -77,7 +75,7 @@ jobs: shell: bash id: set_tag run: | - USER_INPUT="" + 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:-$(uuidgen)} @@ -108,7 +106,7 @@ jobs: - uses: ./.github/actions/build-frontend name: Build frontend with: - api-endpoint: https://reportvision-ocr-dev.azurewebsites.net/ + api-endpoint: https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/ frontend-tarball: ./frontend.tgz frontend-path: ./frontend frontend-build-path: ./frontend/dist/ @@ -117,7 +115,7 @@ jobs: az-environment-setup: name: Setup Azure Environment runs-on: ubuntu-latest - environment: dev + environment: ${{ inputs.deploy-env }} steps: - uses: actions/checkout@v4 - uses: azure/login@v2 @@ -129,8 +127,8 @@ jobs: - uses: ./.github/actions/tf-setup name: Setup this environment with Terraform with: - deploy-env: dev - azure-resource-group: reportvision-rg-dev + 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 }} @@ -140,7 +138,7 @@ jobs: deploy-middleware: name: Deploy middleware runs-on: ubuntu-latest - environment: dev + environment: ${{ inputs.deploy-env }} needs: [build-publish-middleware, az-environment-setup] steps: - uses: actions/checkout@v4 @@ -153,7 +151,7 @@ jobs: - name: Deploy middleware-API uses: ./.github/actions/deploy-api with: - deploy-env: dev + deploy-env: ${{ inputs.deploy-env }} docker-tag: ${{ needs.build-publish-middleware.outputs.docker_tag }} docker-registry: ghcr.io api-name: middleware @@ -161,7 +159,7 @@ jobs: deploy-ocr: name: Deploy OCR runs-on: ubuntu-latest - environment: dev + environment: ${{ inputs.deploy-env }} needs: [build-publish-ocr, az-environment-setup] steps: - uses: actions/checkout@v4 @@ -174,7 +172,7 @@ jobs: - name: Deploy OCR-API uses: ./.github/actions/deploy-api with: - deploy-env: dev + deploy-env: ${{ inputs.deploy-env }} docker-tag: ${{ needs.build-publish-ocr.outputs.docker_tag }} docker-registry: ghcr.io api-name: ocr @@ -182,9 +180,9 @@ jobs: deploy-frontend: name: Deploy Frontend runs-on: ubuntu-latest - environment: dev + environment: ${{ inputs.deploy-env }} needs: [build-frontend, az-environment-setup] - if: ${{ 'dev' != 'demo'}} + if: ${{ inputs.deploy-env != 'demo'}} steps: - uses: actions/checkout@v4 - uses: azure/login@v2 @@ -197,4 +195,4 @@ jobs: uses: ./.github/actions/deploy-frontend with: frontend-tarball: frontend.tgz - deploy-env: dev \ No newline at end of file + deploy-env: ${{ inputs.deploy-env }} \ No newline at end of file