Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy Middleware workflow and tf var removal #487

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/build-deploy-middleware.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Create, publish, deploy a Middleware API image

on:
workflow_dispatch:
inputs:
deploy-env:
description: 'The environment to deploy to'
required: true
type: choice
options:
- dev
- demo
middleware-docker-tag:
description: 'This is optional if you would like to deploy an already published Middleware-API image'
required: false

permissions:
contents: read
packages: write
attestations: write
id-token: write

jobs:
build-publish-middleware:
name: Build and Publish Middleware
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:${{ steps.set_tag.outputs.docker_tag }} > /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: ${{ steps.set_tag.outputs.docker_tag }}
dockerfile-path: ./Backend/Dockerfile
docker-context-path: ./Backend/
api-name: middleware

deploy-middleware:
name: Deploy Middleware
runs-on: ubuntu-latest
environment: ${{ inputs.deploy-env }}
needs: [build-publish-middleware]
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 }}
object-id: ${{ secrets.AZURE_OBJECT_ID }}
- name: Deploy Middleware-API
uses: ./.github/actions/deploy-api
with:
deploy-env: ${{ inputs.deploy-env }}
docker-tag: ${{ needs.build-publish-middleware.outputs.docker_tag }}
docker-registry: ghcr.io
api-name: middleware
2 changes: 0 additions & 2 deletions ops/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ module "middleware_api" {
DEBUG = true
}

lb_subnet_id = module.networking.lbsubnet_id
health_path = "/actuator/health"
env = local.environment
vnet = module.networking.network_name
Expand All @@ -107,7 +106,6 @@ module "ocr_api" {
WEBSITES_PORT = "8000"
}

lb_subnet_id = module.networking.lbsubnet_id
env = local.environment
vnet = module.networking.network_name
sku_name = var.sku_name
Expand Down
Loading