-
Notifications
You must be signed in to change notification settings - Fork 8
97 lines (83 loc) · 3.52 KB
/
deploy-connect-backend.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
91
92
93
94
95
96
97
name: Deploy backend webapp
on:
push:
branches:
- master
- salesforce-integration
- chore/reinstate-terraform-for-azure-migration
- chore/latest-terraform-greek-god-awesome-stuff-terrastos
# paths:
# - 'apps/nestjs-api/**'
# - '.github/workflows/deploy-connect-backend.yml'
jobs:
deploy-staging:
# TODO uncomment when you merge on master
# if: contains(github.ref, 'heads/master') # we want to apply the tf changes only on the `master` branch
environment:
name: staging
url: https://api-staging-redos.azurewebsites.net
runs-on: ubuntu-latest
env:
AZURE_CONTAINER_REGISTRY: ${{ secrets.REGISTRY_NAME }}.azurecr.io
AZURE_IMAGE_NAME_WITH_SHA_TAG: ${{ secrets.REGISTRY_NAME }}.azurecr.io/red-platform-backend:${{ github.sha }}
AZURE_IMAGE_NAME_WITH_LATEST_TAG: ${{ secrets.REGISTRY_NAME }}.azurecr.io/red-platform-backend:latest
steps:
- uses: actions/checkout@master
- name: Azure authentication
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure container registry authentication
uses: azure/docker-login@v1
with:
login-server: ${{ env.AZURE_CONTAINER_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
DOCKER_BUILDKIT=1 docker build -t ${{ env.AZURE_IMAGE_NAME_WITH_SHA_TAG }} -t ${{ env.AZURE_IMAGE_NAME_WITH_LATEST_TAG }} .
docker push ${{ env.AZURE_IMAGE_NAME_WITH_SHA_TAG }}
docker push ${{ env.AZURE_IMAGE_NAME_WITH_LATEST_TAG }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: api-staging-redos
images: ${{ env.AZURE_IMAGE_NAME_WITH_LATEST_TAG }}
- name: Azure logout
run: |
az logout
deploy-production:
# TODO uncomment when you merge on master
# if: contains(github.ref, 'heads/master') # we want to apply the tf changes only on the `master` branch
needs: [deploy-staging]
environment:
name: production
url: https://api-prod-redos.azurewebsites.net
runs-on: ubuntu-latest
env:
AZURE_CONTAINER_REGISTRY: ${{ secrets.REGISTRY_NAME }}.azurecr.io
AZURE_IMAGE_NAME_WITH_SHA_TAG: ${{ secrets.REGISTRY_NAME }}.azurecr.io/red-platform-backend:${{ github.sha }}
AZURE_IMAGE_NAME_WITH_LATEST_TAG: ${{ secrets.REGISTRY_NAME }}.azurecr.io/red-platform-backend:latest
steps:
- uses: actions/checkout@master
- name: Azure authentication
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure container registry authentication
uses: azure/docker-login@v1
with:
login-server: ${{ env.AZURE_CONTAINER_REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build -t ${{ env.AZURE_IMAGE_NAME_WITH_SHA_TAG }} -t ${{ env.AZURE_IMAGE_NAME_WITH_LATEST_TAG }} .
docker push ${{ env.AZURE_IMAGE_NAME_WITH_SHA_TAG }}
docker push ${{ env.AZURE_IMAGE_NAME_WITH_LATEST_TAG }}
- name: Deploy to Azure Web App
uses: azure/webapps-deploy@v2
with:
app-name: api-prod-redos
images: ${{ env.AZURE_IMAGE_NAME_WITH_LATEST_TAG }}
- name: Azure logout
run: |
az logout