Skip to content

Commit

Permalink
Use a SHA for docker tagging instead of typed version (#441)
Browse files Browse the repository at this point in the history
* test build deploy ocr with sha

* test docker image check

* test for new sha

* test for new sha

* test docker tag check

* test docker tag check with prepublished tag

* test with new env tag in deploy

* test docker tag output

* test docker tag output

* test docker tag output

* test docker tag output

* cleanup

* test with sha with middleware

* clean-up

* fix deploy

* fix deploy

---------

Co-authored-by: Administrator <[email protected]>
  • Loading branch information
derekadombek and Administrator authored Dec 3, 2024
1 parent 3e66da6 commit 68d5be6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/actions/deploy-api/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}'
35 changes: 19 additions & 16 deletions .github/workflows/build-deploy-ocr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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
52 changes: 36 additions & 16 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 68d5be6

Please sign in to comment.