Skip to content

Dev Backend Build and Deploy #51

Dev Backend Build and Deploy

Dev Backend Build and Deploy #51

name: Dev Backend Build and Deploy
on:
workflow_dispatch:
push:
branches:
- cml/deploy-new-infra
paths:
- backend/models/**
- backend/ops_api/**
- backend/Dockerfile.ops-api
- '!backend/tests/**'
env:
TF_IN_AUTOMATION: "True"
ENVIRONMENT: "dev"
WORKING_DIR: "backend"
DOCKER_FILE: "Dockerfile.ops-api"
jobs:
build:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- name: Build and publish the Docker image for ${{ github.repository }}
uses: ./.github/actions/build-and-push
with:
image_name: ${{ github.repository }}/ops-${{ env.WORKING_DIR }} # it will be lowercased internally
github_token: ${{ secrets.GITHUB_TOKEN }}
context: ${{ github.workspace }}/${{ env.WORKING_DIR }}
dockerfile: ${{ github.workspace }}/${{ env.WORKING_DIR }}/${{ env.DOCKER_FILE }}
image_tags: '["latest", "${{ github.sha }}"]'
backend-deploy:
needs: build
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- name: Terraform Apply
uses: ./.github/actions/tf-apply
with:
terraform_directory: "terraform/eastus/ops/${{ env.ENVIRONMENT }}/stacks/${{ env.WORKING_DIR }}"
azure_client_id: ${{ secrets.ARM_CLIENT_ID }}
azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }}
azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }}
azure_tenant_id: ${{ secrets.ARM_TENANT_ID }}
github_token: ${{ secrets.GITHUB_TOKEN }}
twingate_service_key: ${{ secrets.TWINGATE_SERVICE_KEY }}
tf_vars: |
{
"environment": "${{ env.ENVIRONMENT }}",
"containerImageTag": "${{ github.sha }}",
"dnsZoneName": "opre-ops.flexion.us",
"backendName": "opre-ops-dev-backend",
"containerAppEnvName": "opre-ops-dev-app-cae",
"resourceGroupName": "opre-ops-dev-app-rg",
"postgresServerName": "opre-ops-dev-db-psql",
"keyVaultName": "opre-ops-dev-kv"
}