generated from DFE-Digital/govuk-dotnet-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 2
90 lines (75 loc) · 3.42 KB
/
app-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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