From 7c4645c689c749c4a5d219d923b639965aab92b8 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 29 Oct 2024 11:26:56 -0600 Subject: [PATCH 01/13] Try to fix Docker image check --- .github/workflows/build-deploy-ocr.yml | 30 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 9c558297..743fbc6a 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -1,15 +1,17 @@ name: Create, publish, deploy a OCR API image on: - workflow_dispatch: - inputs: - tag: - description: 'Version tag for new release' - required: true + push: + branches: fix-docker-image-check + # workflow_dispatch: + # inputs: + # tag: + # description: 'Version tag for new release' + # required: true env: REGISTRY: ghcr.io - VERSION: ${{ inputs.tag }} + VERSION: demo-test-env-derek jobs: @@ -20,6 +22,8 @@ jobs: packages: write attestations: write id-token: write + outputs: + tf_env: ${{ steps.set-environment.outputs.tf_env }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -31,12 +35,16 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Lowercase the repo name run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - # - name: Check if image exists - # id: image_check - # run: docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $? + - name: Check if image exists + id: image_check + run: | + echo "tf_env=$( + docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $? + )" >> $GITHUB_OUTPUT - name: Build and push Docker image id: push uses: docker/build-push-action@v6 + if: ${{ steps.image_check.outputs.tf_env == 1 }} with: context: ./OCR/ file: ./OCR/Dockerfile @@ -51,7 +59,7 @@ jobs: attestations: write id-token: write needs: build-and-push-image - environment: dev + environment: dev3 steps: - uses: azure/login@v2 with: @@ -66,6 +74,6 @@ jobs: id: deploy-to-webapp uses: azure/webapps-deploy@v3 with: - app-name: reportvision-ocr-dev + app-name: reportvision-ocr-dev3 images: '${{ env.REGISTRY }}/${{ env.REPO}}-ocr-api:${{ env.VERSION }}' From 2c46265c65b32a1fc1b5dc1db969838f74167043 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 29 Oct 2024 11:28:58 -0600 Subject: [PATCH 02/13] try with new image name --- .github/workflows/build-deploy-ocr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 743fbc6a..83b836cb 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -11,7 +11,7 @@ on: env: REGISTRY: ghcr.io - VERSION: demo-test-env-derek + VERSION: demo-test-env-derek1 jobs: From 077ec3e0155d23b2905f81e5106286e063bb9e80 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 29 Oct 2024 11:44:50 -0600 Subject: [PATCH 03/13] try with full workflow --- .github/workflows/build-deploy-ocr.yml | 20 ++- .github/workflows/deploy-dev.yml | 181 +++++++++++++------------ 2 files changed, 106 insertions(+), 95 deletions(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 83b836cb..4d137646 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -1,17 +1,15 @@ name: Create, publish, deploy a OCR API image on: - push: - branches: fix-docker-image-check - # workflow_dispatch: - # inputs: - # tag: - # description: 'Version tag for new release' - # required: true + workflow_dispatch: + inputs: + tag: + description: 'Version tag for new release' + required: true env: REGISTRY: ghcr.io - VERSION: demo-test-env-derek1 + VERSION: ${{ inputs.tag }} jobs: @@ -23,7 +21,7 @@ jobs: attestations: write id-token: write outputs: - tf_env: ${{ steps.set-environment.outputs.tf_env }} + docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -38,13 +36,13 @@ jobs: - name: Check if image exists id: image_check run: | - echo "tf_env=$( + echo "docker_inspect=$( docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and push Docker image id: push uses: docker/build-push-action@v6 - if: ${{ steps.image_check.outputs.tf_env == 1 }} + if: ${{ steps.image_check.outputs.docker_inspect == 1 }} with: context: ./OCR/ file: ./OCR/Dockerfile diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index abedd6c1..dd95d6b6 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,23 +1,25 @@ 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 - - dev2 - - dev3 - - dev4 - - dev5 - - dev6 - - demo - ocr-version: - description: 'Create a version for this OCR API image' - required: true + push: + branches: fix-docker-image-check + # workflow_dispatch: + # inputs: + # deploy-env: + # description: 'The environment to deploy to' + # required: true + # type: choice + # options: + # - dev + # - dev2 + # - dev3 + # - dev4 + # - dev5 + # - dev6 + # - demo + # ocr-version: + # description: 'Create a version for this OCR API image' + # required: true permissions: contents: read @@ -28,85 +30,96 @@ permissions: jobs: build-publish-ocr: 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 }}-ocr-api:demo-test-env-derek > /dev/null ; echo $? + )" >> $GITHUB_OUTPUT - name: Build and Push backend + 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.ocr-version }} + docker-tag: demo-test-env-derek dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ api-name: ocr-api - 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-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 - environment-setup: - 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 + # environment-setup: + # 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-backend: - runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - needs: [build-publish-ocr, 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: ${{ inputs.ocr-version }} - docker-registry: ghcr.io - api-name: ocr-api + # deploy-ocr-api: + # runs-on: ubuntu-latest + # environment: ${{ inputs.deploy-env }} + # needs: [build-publish-ocr, 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: ${{ inputs.ocr-version }} + # docker-registry: ghcr.io + # api-name: ocr-api - deploy-frontend: - runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - needs: [build-frontend, 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: + # runs-on: ubuntu-latest + # environment: ${{ inputs.deploy-env }} + # needs: [build-frontend, 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 From 6edde151e1234cdf11c8fce68de7a2dd68c352f4 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 29 Oct 2024 11:46:14 -0600 Subject: [PATCH 04/13] try with new image in full workflow --- .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 dd95d6b6..fe8b5dd2 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -40,7 +40,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:demo-test-env-derek > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:demo-test-env-derek1 > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and Push backend if: ${{ steps.image_check.outputs.docker_inspect == 1 }} @@ -49,7 +49,7 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: demo-test-env-derek + docker-tag: demo-test-env-derek1 dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ api-name: ocr-api From 3c1095e0977e14c596236891229c619a88a9fd6c Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 29 Oct 2024 11:49:07 -0600 Subject: [PATCH 05/13] wip --- .github/workflows/build-deploy-ocr.yml | 16 ++- .github/workflows/deploy-dev.yml | 172 ++++++++++++------------- 2 files changed, 94 insertions(+), 94 deletions(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 4d137646..758b7c8d 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -1,11 +1,13 @@ name: Create, publish, deploy a OCR API image on: - workflow_dispatch: - inputs: - tag: - description: 'Version tag for new release' - required: true + push: + branches: fix-docker-image-check + # workflow_dispatch: + # inputs: + # tag: + # description: 'Version tag for new release' + # required: true env: REGISTRY: ghcr.io @@ -37,7 +39,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $? + docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and push Docker image id: push @@ -47,7 +49,7 @@ jobs: context: ./OCR/ file: ./OCR/Dockerfile push: true - tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} + tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek deploy: runs-on: ubuntu-latest diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index fe8b5dd2..8a9dfd06 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -1,25 +1,23 @@ name: Build and deploy all of ReportVision's services to a development environment on: - push: - branches: fix-docker-image-check - # workflow_dispatch: - # inputs: - # deploy-env: - # description: 'The environment to deploy to' - # required: true - # type: choice - # options: - # - dev - # - dev2 - # - dev3 - # - dev4 - # - dev5 - # - dev6 - # - demo - # ocr-version: - # description: 'Create a version for this OCR API image' - # required: true + workflow_dispatch: + inputs: + deploy-env: + description: 'The environment to deploy to' + required: true + type: choice + options: + - dev + - dev2 + - dev3 + - dev4 + - dev5 + - dev6 + - demo + ocr-version: + description: 'Create a version for this OCR API image' + required: true permissions: contents: read @@ -40,7 +38,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:demo-test-env-derek1 > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:${{ inputs.ocr-version }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and Push backend if: ${{ steps.image_check.outputs.docker_inspect == 1 }} @@ -49,77 +47,77 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: demo-test-env-derek1 + docker-tag: ${{ inputs.ocr-version }} dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ api-name: ocr-api - # 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-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 - # environment-setup: - # 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 + environment-setup: + 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-ocr-api: - # runs-on: ubuntu-latest - # environment: ${{ inputs.deploy-env }} - # needs: [build-publish-ocr, 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: ${{ inputs.ocr-version }} - # docker-registry: ghcr.io - # api-name: ocr-api + deploy-ocr-api: + runs-on: ubuntu-latest + environment: ${{ inputs.deploy-env }} + needs: [build-publish-ocr, 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: ${{ inputs.ocr-version }} + docker-registry: ghcr.io + api-name: ocr-api - # deploy-frontend: - # runs-on: ubuntu-latest - # environment: ${{ inputs.deploy-env }} - # needs: [build-frontend, 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: + runs-on: ubuntu-latest + environment: ${{ inputs.deploy-env }} + needs: [build-frontend, 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 From 8185d29b9fa783e034ae9416608266493e1ed40f Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 29 Oct 2024 11:49:55 -0600 Subject: [PATCH 06/13] wip --- .github/workflows/build-deploy-ocr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 758b7c8d..90c46434 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -39,7 +39,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek > /dev/null ; echo $? + docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek1 > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and push Docker image id: push @@ -49,7 +49,7 @@ jobs: context: ./OCR/ file: ./OCR/Dockerfile push: true - tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek + tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek1 deploy: runs-on: ubuntu-latest From ed944d921efb1a007e81fffc99ffde2978c67bee Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 29 Oct 2024 11:51:11 -0600 Subject: [PATCH 07/13] fixed --- .github/workflows/build-deploy-ocr.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 90c46434..4d137646 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -1,13 +1,11 @@ name: Create, publish, deploy a OCR API image on: - push: - branches: fix-docker-image-check - # workflow_dispatch: - # inputs: - # tag: - # description: 'Version tag for new release' - # required: true + workflow_dispatch: + inputs: + tag: + description: 'Version tag for new release' + required: true env: REGISTRY: ghcr.io @@ -39,7 +37,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek1 > /dev/null ; echo $? + docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and push Docker image id: push @@ -49,7 +47,7 @@ jobs: context: ./OCR/ file: ./OCR/Dockerfile push: true - tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:demo-test-env-derek1 + tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} deploy: runs-on: ubuntu-latest From d4d5622c05c7909e337c8393a6f8fcab05cd3f68 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 4 Nov 2024 12:34:13 -0700 Subject: [PATCH 08/13] test frontend workflow with changes --- .github/workflows/build-deploy-frontend.yml | 86 ++++++++------------- .github/workflows/build-deploy-ocr.yml | 75 +++++++++--------- 2 files changed, 67 insertions(+), 94 deletions(-) diff --git a/.github/workflows/build-deploy-frontend.yml b/.github/workflows/build-deploy-frontend.yml index b698a1bf..2609c6de 100644 --- a/.github/workflows/build-deploy-frontend.yml +++ b/.github/workflows/build-deploy-frontend.yml @@ -1,66 +1,44 @@ name: Build and Deploy Frontend on: - workflow_dispatch: - inputs: - deploy-env: - description: 'The environment to deploy to' - required: true - type: choice - options: - - dev - - dev2 - - dev3 - - dev4 - - dev5 - - dev6 - - demo - demo-blob-name: - description: 'After the demo env gets created, copy its blob storage name here' - required: false + push: + branches: fix-docker-image-check + # workflow_dispatch: + # inputs: + # deploy-env: + # description: 'The environment to deploy to' + # required: true + # type: choice + # options: + # - dev + # - demo + # demo-blob-name: + # description: 'After the demo env gets created, copy its blob storage name here' + # required: false permissions: id-token: write contents: read jobs: - build: - name: Build + build-frontend: runs-on: ubuntu-latest - defaults: - run: - working-directory: frontend - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 + - uses: actions/checkout@v4 + - uses: ./.github/actions/build-frontend + name: Build frontend with: - node-version: '20' - - name: Install NPM packages - run: npm ci - - name: Build project - run: VITE_API_URL='https://reportvision-ocr-${{ inputs.deploy-env }}.azurewebsites.net/' npm run build - - name: Run unit tests - run: npm run test - - name: Create client build archive - shell: bash - run: | - echo "::group::Create application archive" - tar -C ./dist/ -czf ./client.tgz . - echo "::endgroup::" - - name: Upload production-ready build files - uses: actions/upload-artifact@v4 - with: - name: production-files - path: ./frontend/client.tgz + api-endpoint: https://reportvision-ocr-dev.azurewebsites.net/ + frontend-tarball: ./frontend.tgz + frontend-path: ./frontend + frontend-build-path: ./frontend/dist/ + node-version: 20 - deploy: + deploy-with-blob-name-optional: name: Deploy runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - needs: [build] + environment: dev + needs: [build-frontend] steps: - name: Download Artifacts To Job uses: actions/download-artifact@v4 @@ -69,10 +47,8 @@ jobs: - name: Unpack client shell: bash run: | - echo "::group::Unpack client" - mkdir client-build; - tar -C client-build -zxvf client.tgz - echo "::endgroup::" + mkdir frontend-deploy; + tar -C frontend-deploy -zxvf frontend.tgz - name: Azure login uses: azure/login@v2 with: @@ -82,10 +58,10 @@ jobs: - name: Upload to Azure blob storage shell: bash run: | - if [ -z "${{ inputs.demo-blob-name }}" ]; then - az storage blob upload-batch --account-name reportvisionfrontend${{ inputs.deploy-env }} -d '$web' -s client-build/ --overwrite + if [ -z "" ]; then + az storage blob upload-batch --account-name reportvisionfrontenddev -d '$web' -s frontend-deploy/ --overwrite else - az storage blob upload-batch --account-name ${{ inputs.demo-blob-name }} -d '$web' -s client-build/ --overwrite + az storage blob upload-batch --account-name ${{ inputs.demo-blob-name }} -d '$web' -s frontend-deploy/ --overwrite fi - name: Azure logout shell: bash diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 4d137646..62cfed1f 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -3,23 +3,26 @@ name: Create, publish, deploy a OCR API image on: workflow_dispatch: inputs: - tag: - description: 'Version tag for new release' - required: true - -env: - REGISTRY: ghcr.io - VERSION: ${{ inputs.tag }} + deploy-env: + description: 'The environment to deploy to' + required: true + type: choice + options: + - dev + - demo + ocr-version: + description: 'Create a version for this OCR API image' + required: true +permissions: + contents: read + packages: write + attestations: write + id-token: write jobs: build-and-push-image: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - attestations: write - id-token: write outputs: docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} steps: @@ -28,7 +31,7 @@ jobs: - name: Log in to the Container registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Lowercase the repo name @@ -37,41 +40,35 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:${{ inputs.deploy-env }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - - name: Build and push Docker image - id: push - uses: docker/build-push-action@v6 + - name: Build and Push backend if: ${{ steps.image_check.outputs.docker_inspect == 1 }} + uses: ./.github/actions/build-publish-api with: - context: ./OCR/ - file: ./OCR/Dockerfile - push: true - tags: ${{ env.REGISTRY }}/${{ env.REPO }}-ocr-api:${{ env.VERSION }} + docker-registry: ghcr.io + docker-pw: ${{ secrets.GITHUB_TOKEN }} + docker-username: ${{ github.actor }} + docker-tag: ${{ inputs.ocr-version }} + dockerfile-path: ./OCR/Dockerfile + docker-context-path: ./OCR/ + api-name: ocr-api - deploy: + deploy-ocr-api: runs-on: ubuntu-latest - permissions: - contents: read - packages: write - attestations: write - id-token: write - needs: build-and-push-image - environment: dev3 + environment: ${{ inputs.deploy-env }} + needs: [build-and-push-image] 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: Lowercase the repo name - run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - - - name: Deploy to Azure Web App - id: deploy-to-webapp - uses: azure/webapps-deploy@v3 + - name: Deploy OCR-API + uses: ./.github/actions/deploy-api with: - app-name: reportvision-ocr-dev3 - images: '${{ env.REGISTRY }}/${{ env.REPO}}-ocr-api:${{ env.VERSION }}' - + deploy-env: ${{ inputs.deploy-env }} + docker-tag: ${{ inputs.ocr-version }} + docker-registry: ghcr.io + api-name: ocr-api From 4a8f6cb3d4485c56d8adb543fc5d5abac4bcf0de Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 4 Nov 2024 12:37:52 -0700 Subject: [PATCH 09/13] test frontend workflow with changes --- .github/workflows/build-deploy-frontend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deploy-frontend.yml b/.github/workflows/build-deploy-frontend.yml index 2609c6de..50f5c307 100644 --- a/.github/workflows/build-deploy-frontend.yml +++ b/.github/workflows/build-deploy-frontend.yml @@ -43,7 +43,7 @@ jobs: - name: Download Artifacts To Job uses: actions/download-artifact@v4 with: - name: production-files + name: frontend-tarball - name: Unpack client shell: bash run: | From a52b16214ab1a425772828ff3b984922d623f57a Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 4 Nov 2024 12:55:40 -0700 Subject: [PATCH 10/13] test ocr build and deploy with changes --- .github/workflows/build-deploy-frontend.yml | 34 ++++++++-------- .github/workflows/build-deploy-ocr.yml | 44 +++++++++++---------- .github/workflows/deploy-dev.yml | 7 +++- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-deploy-frontend.yml b/.github/workflows/build-deploy-frontend.yml index 50f5c307..40c1206a 100644 --- a/.github/workflows/build-deploy-frontend.yml +++ b/.github/workflows/build-deploy-frontend.yml @@ -1,20 +1,18 @@ name: Build and Deploy Frontend on: - push: - branches: fix-docker-image-check - # workflow_dispatch: - # inputs: - # deploy-env: - # description: 'The environment to deploy to' - # required: true - # type: choice - # options: - # - dev - # - demo - # demo-blob-name: - # description: 'After the demo env gets created, copy its blob storage name here' - # required: false + workflow_dispatch: + inputs: + deploy-env: + description: 'The environment to deploy to' + required: true + type: choice + options: + - dev + - demo + demo-blob-name: + description: 'After the demo env gets created, copy its blob storage name here' + required: false permissions: id-token: write @@ -28,7 +26,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/ @@ -37,7 +35,7 @@ jobs: deploy-with-blob-name-optional: name: Deploy runs-on: ubuntu-latest - environment: dev + environment: ${{ inputs.deploy-env }} needs: [build-frontend] steps: - name: Download Artifacts To Job @@ -58,8 +56,8 @@ jobs: - name: Upload to Azure blob storage shell: bash run: | - if [ -z "" ]; then - az storage blob upload-batch --account-name reportvisionfrontenddev -d '$web' -s frontend-deploy/ --overwrite + if [ -z "${{ inputs.demo-blob-name }}" ]; then + az storage blob upload-batch --account-name reportvisionfrontend${{ inputs.deploy-env }} -d '$web' -s frontend-deploy/ --overwrite else az storage blob upload-batch --account-name ${{ inputs.demo-blob-name }} -d '$web' -s frontend-deploy/ --overwrite fi diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 62cfed1f..e6a17ebc 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -1,18 +1,20 @@ name: Create, publish, deploy a OCR API image on: - workflow_dispatch: - inputs: - deploy-env: - description: 'The environment to deploy to' - required: true - type: choice - options: - - dev - - demo - ocr-version: - description: 'Create a version for this OCR API image' - required: true + push: + branches: fix-docker-image-check + # workflow_dispatch: + # inputs: + # deploy-env: + # description: 'The environment to deploy to' + # required: true + # type: choice + # options: + # - dev + # - demo + # ocr-version: + # description: 'Create a version for this OCR API image' + # required: true permissions: contents: read @@ -21,7 +23,8 @@ permissions: id-token: write jobs: - build-and-push-image: + build-publish-ocr: + name: Build and Publish OCR runs-on: ubuntu-latest outputs: docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} @@ -40,7 +43,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:${{ inputs.deploy-env }} > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:derek-clean-up-test > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and Push backend if: ${{ steps.image_check.outputs.docker_inspect == 1 }} @@ -49,15 +52,16 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: ${{ inputs.ocr-version }} + docker-tag: derek-clean-up-test dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ api-name: ocr-api - deploy-ocr-api: + deploy-ocr: + name: Deploy OCR runs-on: ubuntu-latest - environment: ${{ inputs.deploy-env }} - needs: [build-and-push-image] + environment: dev + needs: [build-publish-ocr] steps: - uses: actions/checkout@v4 - uses: azure/login@v2 @@ -68,7 +72,7 @@ jobs: - name: Deploy OCR-API uses: ./.github/actions/deploy-api with: - deploy-env: ${{ inputs.deploy-env }} - docker-tag: ${{ inputs.ocr-version }} + deploy-env: dev + docker-tag: derek-clean-up-test docker-registry: ghcr.io api-name: ocr-api diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 8a9dfd06..8b3b40ab 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -27,6 +27,7 @@ permissions: jobs: build-publish-ocr: + name: Build and Publish OCR runs-on: ubuntu-latest outputs: docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} @@ -53,6 +54,7 @@ jobs: api-name: ocr-api build-frontend: + name: Build Frontend runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -66,6 +68,7 @@ jobs: node-version: 20 environment-setup: + name: Setup Azure Environment runs-on: ubuntu-latest environment: ${{ inputs.deploy-env }} steps: @@ -85,7 +88,8 @@ jobs: azure-subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} app-name: reportvision - deploy-ocr-api: + deploy-ocr: + name: Deploy OCR runs-on: ubuntu-latest environment: ${{ inputs.deploy-env }} needs: [build-publish-ocr, environment-setup] @@ -105,6 +109,7 @@ jobs: api-name: ocr-api deploy-frontend: + name: Deploy Frontend runs-on: ubuntu-latest environment: ${{ inputs.deploy-env }} needs: [build-frontend, environment-setup] From e97b4e7912cf1deae3457b0722fd46eab6cf6c72 Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 4 Nov 2024 13:00:12 -0700 Subject: [PATCH 11/13] test with already registered docker images --- .github/workflows/build-deploy-ocr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index e6a17ebc..edb13eb8 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -43,7 +43,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:derek-clean-up-test > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:resusable-deploy-test-derek > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and Push backend if: ${{ steps.image_check.outputs.docker_inspect == 1 }} @@ -52,7 +52,7 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: derek-clean-up-test + docker-tag: resusable-deploy-test-derek dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ api-name: ocr-api @@ -73,6 +73,6 @@ jobs: uses: ./.github/actions/deploy-api with: deploy-env: dev - docker-tag: derek-clean-up-test + docker-tag: resusable-deploy-test-derek docker-registry: ghcr.io api-name: ocr-api From 3007c3a49461f8aeea84d863965f74f1dc9fd21b Mon Sep 17 00:00:00 2001 From: Administrator Date: Mon, 4 Nov 2024 13:07:42 -0700 Subject: [PATCH 12/13] clean-up worked --- .github/workflows/build-deploy-ocr.yml | 36 ++++++++++++-------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index edb13eb8..79bf2f4f 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -1,20 +1,18 @@ name: Create, publish, deploy a OCR API image on: - push: - branches: fix-docker-image-check - # workflow_dispatch: - # inputs: - # deploy-env: - # description: 'The environment to deploy to' - # required: true - # type: choice - # options: - # - dev - # - demo - # ocr-version: - # description: 'Create a version for this OCR API image' - # required: true + workflow_dispatch: + inputs: + deploy-env: + description: 'The environment to deploy to' + required: true + type: choice + options: + - dev + - demo + ocr-version: + description: 'Create a version for this OCR API image' + required: true permissions: contents: read @@ -43,7 +41,7 @@ jobs: id: image_check run: | echo "docker_inspect=$( - docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:resusable-deploy-test-derek > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr-api:${{ inputs.ocr-version }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and Push backend if: ${{ steps.image_check.outputs.docker_inspect == 1 }} @@ -52,7 +50,7 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: resusable-deploy-test-derek + docker-tag: ${{ inputs.ocr-version }} dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ api-name: ocr-api @@ -60,7 +58,7 @@ jobs: deploy-ocr: name: Deploy OCR runs-on: ubuntu-latest - environment: dev + environment: ${{ inputs.deploy-env }} needs: [build-publish-ocr] steps: - uses: actions/checkout@v4 @@ -72,7 +70,7 @@ jobs: - name: Deploy OCR-API uses: ./.github/actions/deploy-api with: - deploy-env: dev - docker-tag: resusable-deploy-test-derek + deploy-env: ${{ inputs.deploy-env }} + docker-tag: ${{ inputs.ocr-version }} docker-registry: ghcr.io api-name: ocr-api From 6e8c1f0beb890ab03fe478d580a57a466586c391 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 5 Nov 2024 13:17:52 -0700 Subject: [PATCH 13/13] wip --- .github/workflows/build-deploy-frontend.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-deploy-frontend.yml b/.github/workflows/build-deploy-frontend.yml index 40c1206a..5a1432e0 100644 --- a/.github/workflows/build-deploy-frontend.yml +++ b/.github/workflows/build-deploy-frontend.yml @@ -10,7 +10,7 @@ on: options: - dev - demo - demo-blob-name: + storage-account-name: description: 'After the demo env gets created, copy its blob storage name here' required: false @@ -56,10 +56,10 @@ jobs: - name: Upload to Azure blob storage shell: bash run: | - if [ -z "${{ inputs.demo-blob-name }}" ]; then + if [ -z "${{ inputs.storage-account-name }}" ]; then az storage blob upload-batch --account-name reportvisionfrontend${{ inputs.deploy-env }} -d '$web' -s frontend-deploy/ --overwrite else - az storage blob upload-batch --account-name ${{ inputs.demo-blob-name }} -d '$web' -s frontend-deploy/ --overwrite + az storage blob upload-batch --account-name ${{ inputs.storage-account-name }} -d '$web' -s frontend-deploy/ --overwrite fi - name: Azure logout shell: bash