Skip to content
Draft
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
39 changes: 39 additions & 0 deletions .github/workflows/app-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy Application

on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
APP_SERVICE_NAME:
required: true
type: string
secrets:
AZURE_CREDENTIALS:
required: true

jobs:
deploy-application:
runs-on: ubuntu-latest
environment: ${{ inputs.ENVIRONMENT }}
steps:

# Download application artifacts from build
- name: Download Application Artifacts
uses: actions/download-artifact@v3
with:
name: api

# Log into Azure
- name: Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Deploy Web API
- name: Deploy API
uses: azure/webapps-deploy@v2
with:
app-name: ${{ inputs.APP_SERVICE_NAME }}
package: './api.zip'
70 changes: 70 additions & 0 deletions .github/workflows/infra-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Deploy Infrastructure

on:
workflow_call:
inputs:
ENVIRONMENT:
required: true
type: string
RESOURCE_GROUP:
required: true
type: string
APP_SERVICE_PLAN:
required: true
type: string
APP_SERVICE_PLAN_RESOURCE_GROUP:
required: true
type: string
secrets:
AZURE_CREDENTIALS:
required: true
SQL_ADMIN_GROUP:
required: true
SQL_ADMIN_GROUP_SID:
required: true
outputs:
appServiceName:
description: "The name of the created App Service"
value: ${{ jobs.deploy-infrastructure.outputs.appServiceName }}

jobs:
deploy-infrastructure:
runs-on: ubuntu-latest
environment: ${{ inputs.ENVIRONMENT }}
outputs:
appServiceName: ${{ steps.bicep.outputs.appServiceName }}
steps:

# Download infrastructure artifacts from build
- name: Download Infrastructure Artifacts
uses: actions/download-artifact@v3
with:
name: infra

# Log into Azure
- name: Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Create Azure infrastructure
- name: Azure deploy
id: bicep
shell: pwsh
env:
sqlAdminGroup: ${{ secrets.SQL_ADMIN_GROUP }}
sqlAdminSid: ${{ secrets.SQL_ADMIN_GROUP_SID }}
run: |
$out = az deployment group create `
--resource-group ${{ inputs.RESOURCE_GROUP }} `
--template-file .\main.bicep `
--parameters environment=${{ inputs.ENVIRONMENT }} `
appServicePlanName=${{ inputs.APP_SERVICE_PLAN }} `
appServicePlanResourceGroup=${{ inputs.APP_SERVICE_PLAN_RESOURCE_GROUP }} `
sqlAdministratorsLoginName=$env:sqlAdminGroup `
sqlAdministratorsObjectId=$env:sqlAdminSid `
| convertfrom-json | foreach properties | foreach outputs
$out | Get-Member -MemberType NoteProperty | ForEach-Object {
$keyname = $_.Name
$value = $out.$keyname.value
echo "::set-output name=$keyname::$value" }
54 changes: 42 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
name: Build and upload artifacts
uses: ./.github/workflows/build.yml

deploy_dev:
deploy_infra_dev:
needs: build
name: Deploy dev
uses: ./.github/workflows/az-deploy.yml
name: Deploy dev infrastructure
uses: ./.github/workflows/infra-deploy.yml
with:
ENVIRONMENT: dev
RESOURCE_GROUP: LC.API.Dev
Expand All @@ -24,10 +24,20 @@ jobs:
SQL_ADMIN_GROUP: ${{ secrets.SQL_ADMIN_GROUP }}
SQL_ADMIN_GROUP_SID: ${{ secrets.SQL_ADMIN_GROUP_SID }}

deploy_staging:
needs: deploy_dev
name: Deploy staging
uses: ./.github/workflows/az-deploy.yml
deploy_app_dev:
needs: deploy_infra_dev
name: Deploy dev application
uses: ./.github/workflows/app-deploy.yml
with:
ENVIRONMENT: dev
APP_SERVICE_NAME: ${{ needs.deploy_infra_dev.outputs.appServiceName }}
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}

deploy_infra_staging:
needs: deploy_app_dev
name: Deploy staging infrastructure
uses: ./.github/workflows/infra-deploy.yml
with:
ENVIRONMENT: staging
RESOURCE_GROUP: LC.API.Staging
Expand All @@ -38,10 +48,20 @@ jobs:
SQL_ADMIN_GROUP: ${{ secrets.SQL_ADMIN_GROUP }}
SQL_ADMIN_GROUP_SID: ${{ secrets.SQL_ADMIN_GROUP_SID }}

deploy_prod:
needs: deploy_staging
name: Deploy prod
uses: ./.github/workflows/az-deploy.yml
deploy_app_staging:
needs: deploy_infra_staging
name: Deploy staging application
uses: ./.github/workflows/app-deploy.yml
with:
ENVIRONMENT: staging
APP_SERVICE_NAME: ${{ needs.deploy_infra_staging.outputs.appServiceName }}
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}

deploy_infra_prod:
needs: deploy_app_staging
name: Deploy prod infrastructure
uses: ./.github/workflows/infra-deploy.yml
with:
ENVIRONMENT: prod
RESOURCE_GROUP: LC.API.Production
Expand All @@ -50,4 +70,14 @@ jobs:
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
SQL_ADMIN_GROUP: ${{ secrets.SQL_ADMIN_GROUP }}
SQL_ADMIN_GROUP_SID: ${{ secrets.SQL_ADMIN_GROUP_SID }}
SQL_ADMIN_GROUP_SID: ${{ secrets.SQL_ADMIN_GROUP_SID }}

deploy_app_prod:
needs: deploy_infra_prod
name: Deploy prod application
uses: ./.github/workflows/app-deploy.yml
with:
ENVIRONMENT: prod
APP_SERVICE_NAME: ${{ needs.deploy_infra_prod.outputs.appServiceName }}
secrets:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}