App Deploy #222
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: App Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Docker image tag to deploy' | |
required: true | |
default: 'v1.0.0' | |
workspace: | |
description: 'Environment to deploy to on Azure' | |
required: true | |
default: 'Dev' | |
type: choice | |
options: | |
- Dev | |
- Test | |
- Pre-Prod | |
- Prod | |
- Load-Test | |
jobs: | |
app-deploy: | |
name: 'App Deploy' | |
runs-on: ubuntu-latest | |
environment: ${{inputs.workspace}} | |
steps: | |
- name: Docker pull check | |
run: docker pull ghcr.io/dfe-digital/childrens-social-care-cpd:${{inputs.tag}} | |
- name: Sign in to Azure | |
uses: azure/login@v1 | |
with: | |
creds: '{"clientId":"${{ secrets.TF_ARM_CLIENT_ID }}","clientSecret":"${{ secrets.TF_ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.TF_ARM_SUBSCRIPTION_ID }}","tenantId":"${{ secrets.TF_ARM_TENANT_ID }}"}' | |
- name: Deploy Dev to Azure Web App | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: 's185d01-chidrens-social-care-cpd-app-service' | |
images: 'ghcr.io/dfe-digital/childrens-social-care-cpd:${{ inputs.tag }}' | |
if: ${{ inputs.workspace == 'Dev' }} | |
- name: Deploy Test to Azure Web App | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: 's185d02-chidrens-social-care-cpd-app-service' | |
images: 'ghcr.io/dfe-digital/childrens-social-care-cpd:${{ inputs.tag }}' | |
if: ${{ inputs.workspace == 'Test' }} | |
- name: Deploy Load-Test to Azure Web App | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: 's185d03-chidrens-social-care-cpd-app-service' | |
slot-name: 'staging' | |
images: 'ghcr.io/dfe-digital/childrens-social-care-cpd:${{ inputs.tag }}' | |
if: ${{ inputs.workspace == 'Load-Test' }} | |
- name: Swap slots for Load-Test | |
run: az webapp deployment slot swap -g s185d03-childrens-social-care-cpd-rg -n s185d03-chidrens-social-care-cpd-app-service --slot staging --target-slot production | |
if: ${{ inputs.workspace == 'Load-Test' }} | |
- name: Deploy Pre-Prod to Azure Web App | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: 's185t01-chidrens-social-care-cpd-app-service' | |
images: 'ghcr.io/dfe-digital/childrens-social-care-cpd:${{ inputs.tag }}' | |
if: ${{ inputs.workspace == 'Pre-Prod' }} | |
- name: Deploy Prod to Azure Web App | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: 's185p01-chidrens-social-care-cpd-app-service' | |
slot-name: 'staging' | |
images: 'ghcr.io/dfe-digital/childrens-social-care-cpd:${{ inputs.tag }}' | |
if: ${{ inputs.workspace == 'Prod' }} | |
- name: Swap slots for Prod | |
run: az webapp deployment slot swap -g s185p01-childrens-social-care-cpd-rg -n s185p01-chidrens-social-care-cpd-app-service --slot staging --target-slot production | |
if: ${{ inputs.workspace == 'Prod' }} | |
- name: Write application tag into environment variable | |
run: | | |
curl -L -i -X PATCH -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.PAT }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repositories/547182049/environments/${{ inputs.workspace }}/variables/TF_VAR_CPD_IMAGE_TAG -d '{"name": "TF_VAR_CPD_IMAGE_TAG", "value": "${{ inputs.tag }}"}' | |
- name: Sign out of Azure | |
run: | | |
az logout | |