-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (67 loc) · 2.6 KB
/
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
name: Deployment
on:
workflow_call:
inputs:
environment:
type: string
required: true
description: "Target Environment. Can either be 'dev' or 'prd'"
jobs:
build-all:
name: Build codebase
uses: ./.github/actions/build.yml
with:
push_image: true
secrets: inherit
deploy:
needs: [build-all]
name: Azure Deployment
runs-on: ubuntu-22.04
environment:
name: ${{ inputs.environment }}
url: ${{ vars.AZURE_SUBSCRIPTION_URL }}
concurrency:
group: ${{ inputs.environment }}
cancel-in-progress: false
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: arm
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy ARM template
uses: azure/arm-deploy@v1
with:
subscriptionId: ${{ vars.AZURE_SUBSCRIPTION_ID }}
scope: subscription
region: "West Europe"
template: azuredeploy.json
parameters: "environment=${{ inputs.environment }}"
deploymentName: "azuredeploy-${{github.run_number}}"
failOnStdErr: true
- name: Deploy analog core
id: webapp-deploy
uses: azure/webapps-deploy@v2
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
images: "ghcr.io/analogio/coffeecard-api:${{ github.sha }}"
- name: Invoke Web App CD Webhook
run: |
curl --location --request POST '${{ vars.AZURE_APPSERVICE_WEBHOOK_URL }}' --header 'Authorization: Basic ${{ secrets.AZURE_APPSERVICE_WEBHOOK_AUTH }}'
- name: Smoke tests
uses: Azure/powershell@v1
with:
inlineScript: |
$apiKey = az keyvault secret show --name IdentitySettings-ApiKey --vault-name ${{ vars.KEY_VAULT_NAME }} | ConvertFrom-Json | Select -ExpandProperty value
$header = @{'x-api-key' = $apiKey}
Write-Host 'Running smoke tests' -ForegroundColor Yellow
Write-Host '- GET /api/v2/health/ping'
Invoke-RestMethod -Method Get -Uri ${{ steps.webapp-deploy.outputs.webapp-url }}/api/v2/health/ping -Headers $header -MaximumRetryCount 4 -RetryIntervalSec 15
Write-Host '- GET /api/v2/health/check'
Invoke-RestMethod -Method Get -Uri ${{ steps.webapp-deploy.outputs.webapp-url }}/api/v2/health/check -Headers $header -MaximumRetryCount 4 -RetryIntervalSec 15
Write-Host 'Smoke tests successful!' -ForegroundColor Green
failOnStandardError: true
azPSVersion: "latest"