Merge pull request #3216 from HHS/OPS-3215/can-history-api-spec #120
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Staging Backend Build and Deploy | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- backend/** | |
env: | |
WORKING_DIR: "backend" | |
DT_DOCKER_FILE: "Dockerfile.data-tools-import" | |
BE_DOCKER_FILE: "Dockerfile.ops-api" | |
ENVIRONMENT: stg | |
jobs: | |
build-data-tools: | |
permissions: | |
contents: read | |
packages: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Build and publish the Docker image for ${{ github.repository }} | |
uses: ./.github/actions/build-and-push | |
with: | |
image_name: ${{ github.repository }}/ops-data-tools # it will be lowercased internally | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
context: ${{ github.workspace }}/${{ env.WORKING_DIR }} | |
dockerfile: ${{ github.workspace }}/${{ env.WORKING_DIR }}/${{ env.DT_DOCKER_FILE }} | |
image_tags: "${{ github.sha }}" | |
build-backend: | |
permissions: | |
contents: read | |
packages: write | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Build and publish the Docker image for ${{ github.repository }} | |
uses: ./.github/actions/build-and-push | |
with: | |
image_name: ${{ github.repository }}/ops-backend # it will be lowercased internally | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
context: ${{ github.workspace }}/${{ env.WORKING_DIR }} | |
dockerfile: ${{ github.workspace }}/${{ env.WORKING_DIR }}/${{ env.BE_DOCKER_FILE }} | |
image_tags: "${{ github.sha }}" | |
deploy-data-tools: | |
needs: build-data-tools | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Log in to Azure | |
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0 | |
with: | |
creds: ${{ secrets.SDLC_AZURE_CREDS }} | |
- name: Trigger Data-Tools Job | |
uses: azure/cli@089eac9d8cc39f5d003e94f8b65efc51076c9cbd # v2 | |
with: | |
azcliversion: latest | |
inlineScript: | | |
# Update job to this image | |
az containerapp job update -n opre-ops-${{ env.ENVIRONMENT }}-app-up-schema -g opre-ops-${{ env.ENVIRONMENT }}-app-rg --image ghcr.io/hhs/opre-ops/ops-data-tools:${{ github.sha }} | |
az containerapp job update -n opre-ops-${{ env.ENVIRONMENT }}-app-down-schema -g opre-ops-${{ env.ENVIRONMENT }}-app-rg --image ghcr.io/hhs/opre-ops/ops-data-tools:${{ github.sha }} | |
az containerapp job update -n opre-ops-${{ env.ENVIRONMENT }}-app-data-tools -g opre-ops-${{ env.ENVIRONMENT }}-app-rg --image ghcr.io/hhs/opre-ops/ops-data-tools:${{ github.sha }} | |
# Start the DB schema update job | |
az containerapp job start -n opre-ops-${{ env.ENVIRONMENT }}-app-up-schema -g opre-ops-${{ env.ENVIRONMENT }}-app-rg | |
deploy-backend: | |
needs: build-backend | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Log in to Azure | |
uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0 | |
with: | |
creds: ${{ secrets.SDLC_AZURE_CREDS }} | |
- name: Deploy Container App | |
uses: azure/container-apps-deploy-action@5f5f4c56ca90376e3cfbd76ba8fe8533c784e655 # v2 | |
with: | |
containerAppName: opre-ops-${{ env.ENVIRONMENT }}-app-${{ env.WORKING_DIR }} | |
resourceGroup: opre-ops-${{ env.ENVIRONMENT }}-app-rg | |
imageToDeploy: ghcr.io/hhs/opre-ops/ops-backend:${{ github.sha }} |