Skip to content

Commit

Permalink
Merge pull request #2742 from HHS/cml/add-prod-pipeline
Browse files Browse the repository at this point in the history
Cml/add prod pipeline
  • Loading branch information
devops-chris authored Sep 4, 2024
2 parents 8c2a029 + 8dee6ef commit 917729c
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/prod_be_build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Staging Backend Build and Deploy

on:
workflow_dispatch:

env:
WORKING_DIR: "backend"
DT_DOCKER_FILE: "Dockerfile.data-tools-import"
BE_DOCKER_FILE: "Dockerfile.ops-api"
ENVIRONMENT: prod

jobs:
# build-data-tools:
# permissions:
# contents: read
# packages: write
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# - 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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- 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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

# - name: Log in to Azure
# uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1
# with:
# creds: ${{ secrets.PROD_AZURE_CREDS }}

# - name: Trigger Data-Tools Job
# uses: azure/cli@965c8d7571d2231a54e321ddd07f7b10317f34d9 # v2
# with:
# azcliversion: latest
# inlineScript: |
# # Update job to this image
# 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 data-tools job
# az containerapp job start -n opre-ops-${{ env.ENVIRONMENT }}-app-data-tools -g opre-ops-${{ env.ENVIRONMENT }}-app-rg

# - name: Deploy Container App
# uses: azure/container-apps-deploy-action@5f5f4c56ca90376e3cfbd76ba8fe8533c784e655 # v2
# with:
# # azureCredentials: ${{ secrets.AZURE_CREDS }}
# containerAppName: opre-ops-${{ env.ENVIRONMENT }}-data-tools
# resourceGroup: opre-ops-services-${{ env.ENVIRONMENT }}-app
# imageToDeploy: ghcr.io/hhs/opre-ops/ops-data-tools:${{ github.sha }}

deploy-backend:
needs: build-backend

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Log in to Azure
uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1
with:
creds: ${{ secrets.PROD_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 }}
48 changes: 48 additions & 0 deletions .github/workflows/prod_fe_build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Staging Frontend Build and Deploy

on:
workflow_dispatch:

env:
WORKING_DIR: "frontend"
DOCKER_FILE: "Dockerfile.azure"
ENVIRONMENT: prod
DOMAIN_NAME: "ops.opre.acf.gov"

jobs:
build-frontend:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- 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: "${{ github.sha }},${{ env.ENVIRONMENT }}"
build_args: "VITE_BACKEND_DOMAIN=https://${{ env.ENVIRONMENT }}.${{ env.DOMAIN_NAME }}, MODE=production"

deploy-frontend:
needs: build-frontend

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Log in to Azure
uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1
with:
creds: ${{ secrets.PROD_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-${{ env.WORKING_DIR }}:${{ github.sha }}

0 comments on commit 917729c

Please sign in to comment.