diff --git a/.github/actions/deploy-api/action.yml b/.github/actions/deploy-api/action.yml index 786e6a1e..277a192f 100644 --- a/.github/actions/deploy-api/action.yml +++ b/.github/actions/deploy-api/action.yml @@ -24,5 +24,5 @@ runs: id: deploy-to-webapp uses: azure/webapps-deploy@v3 with: - app-name: reportvision-ocr-${{ inputs.deploy-env }} + app-name: reportvision-${{ inputs.api-name}}-${{ inputs.deploy-env }} images: '${{ inputs.docker-registry }}/${{ env.REPO}}-${{ inputs.api-name }}:${{ inputs.docker-tag }}' \ No newline at end of file diff --git a/.github/workflows/build-deploy-ocr.yml b/.github/workflows/build-deploy-ocr.yml index 79bf2f4f..527f9bbc 100644 --- a/.github/workflows/build-deploy-ocr.yml +++ b/.github/workflows/build-deploy-ocr.yml @@ -10,9 +10,9 @@ on: options: - dev - demo - ocr-version: - description: 'Create a version for this OCR API image' - required: true + ocr-docker-tag: + description: 'This is optional if you would like to deploy an already published OCR-API image' + required: false permissions: contents: read @@ -26,22 +26,25 @@ jobs: runs-on: ubuntu-latest outputs: docker_inspect: ${{ steps.image_check.outputs.docker_inspect }} + docker_tag: ${{ steps.set_tag.outputs.docker_tag }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Log in to the Container registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + - 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:${{ inputs.ocr-version }} > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr:${{ steps.set_tag.outputs.docker_tag }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and Push backend if: ${{ steps.image_check.outputs.docker_inspect == 1 }} @@ -50,10 +53,10 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: ${{ inputs.ocr-version }} + docker-tag: ${{ steps.set_tag.outputs.docker_tag }} dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ - api-name: ocr-api + api-name: ocr deploy-ocr: name: Deploy OCR @@ -71,6 +74,6 @@ jobs: uses: ./.github/actions/deploy-api with: deploy-env: ${{ inputs.deploy-env }} - docker-tag: ${{ inputs.ocr-version }} + docker-tag: ${{ needs.build-publish-ocr.outputs.docker_tag }} docker-registry: ghcr.io - api-name: ocr-api + api-name: ocr diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 2398cfad..2c3a35c7 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -10,12 +10,12 @@ on: options: - dev - demo - 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 + 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 @@ -29,15 +29,25 @@ jobs: 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 Middleware Docker tag + shell: bash + id: set_tag + run: | + 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:-"${{ github.sha }}"} + )" >> $GITHUB_OUTPUT - 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 $? + docker manifest inspect ghcr.io/${{ env.REPO }}-middleware:${{ steps.set_tag.outputs.docker_tag }} > /dev/null ; echo $? )" >> $GITHUB_OUTPUT - name: Build and Push the middleware if: ${{ steps.image_check.outputs.docker_inspect == 1 }} @@ -46,25 +56,35 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: ${{ inputs.middleware-version }} + docker-tag: ${{ steps.set_tag.outputs.docker_tag }} dockerfile-path: ./backend/Dockerfile docker-context-path: ./backend/ - api-name: middleware-api + api-name: middleware 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:${{ inputs.ocr-version }} > /dev/null ; echo $? + docker manifest inspect ghcr.io/${{ env.REPO }}-ocr:${{ 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 }} @@ -73,10 +93,10 @@ jobs: docker-registry: ghcr.io docker-pw: ${{ secrets.GITHUB_TOKEN }} docker-username: ${{ github.actor }} - docker-tag: ${{ inputs.ocr-version }} + docker-tag: ${{ steps.set_tag.outputs.docker_tag }} dockerfile-path: ./OCR/Dockerfile docker-context-path: ./OCR/ - api-name: ocr-api + api-name: ocr build-frontend: name: Build Frontend @@ -129,9 +149,9 @@ jobs: uses: ./.github/actions/deploy-api with: deploy-env: ${{ inputs.deploy-env }} - docker-tag: ${{ inputs.middleware-version }} + docker-tag: ${{ needs.build-publish-middleware.outputs.docker_tag }} docker-registry: ghcr.io - api-name: middleware-api + api-name: middleware deploy-ocr: name: Deploy OCR @@ -149,9 +169,9 @@ jobs: uses: ./.github/actions/deploy-api with: deploy-env: ${{ inputs.deploy-env }} - docker-tag: ${{ inputs.ocr-version }} + docker-tag: ${{ needs.build-publish-ocr.outputs.docker_tag }} docker-registry: ghcr.io - api-name: ocr-api + api-name: ocr deploy-frontend: name: Deploy Frontend