-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (96 loc) · 3.67 KB
/
deploy-to-environment.yml
File metadata and controls
109 lines (96 loc) · 3.67 KB
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
98
99
100
101
102
103
104
105
106
107
108
name: Deployment
on:
workflow_call:
inputs:
resource-group-base-name:
description: 'Resource Group base name'
default: 'kyleburnsdev-springboot'
required: false
type: string
environment-suffix:
description: 'The suffix to be used for the current environment'
default: 'dev'
required: false
type: string
resource-group-location:
description: 'Azure region for the deployed resources'
default: 'eastus'
required: false
type: string
secrets:
azure-credentials:
description: 'Credentials used to log into Azure for deployment of resources'
required: true
jobs:
deploy_to_environment:
runs-on: ubuntu-latest
env:
RESOURCE_GROUP_NAME: ${{ inputs.resource-group-base-name }}-${{ inputs.environment-suffix }}
permissions:
contents: read
packages: write
steps:
- name: Download Artifacts
uses: actions/download-artifact@v3
- name: Establish AZ connection
uses: azure/login@v1
with:
creds: ${{ secrets.azure-credentials }}
- name: Ensure Resource Group Exists
uses: Azure/CLI@v1
with:
inlineScript: |
#!/bin/bash
az group create --name ${{ env.RESOURCE_GROUP_NAME }} --location ${{ inputs.resource-group-location }}
- name: Infra
id: Infra
uses: azure/arm-deploy@v1
with:
resourceGroupName: ${{ env.RESOURCE_GROUP_NAME }}
template: ./infra/main.json
- name: DbAdmin
id: DbAdmin
uses: azure/CLI@v1
with:
inlineScript: |
az postgres flexible-server ad-admin create --server-name ${{ steps.Infra.outputs.postgreSqlResourceName }} \
-g ${{ env.RESOURCE_GROUP_NAME }} \
--display-name ${{ steps.Infra.outputs.websiteName }} \
--object-id ${{ steps.Infra.outputs.websiteIdentity }} \
-t ServicePrincipal
- name: App
uses: azure/webapps-deploy@v2
with:
app-name: ${{ steps.Infra.outputs.websiteName }}
package: ./app/app.jar
# - name: Generate Temporary API Key For App Insights
# id: AIKeyGen
# uses: Azure/CLI@v1
# with:
# inlineScript: |
# az config set extension.use_dynamic_install=yes_without_prompt
# result=$(az monitor app-insights api-key create \
# --api-key ${{ steps.Infra.outputs.releaseAnnotationId }} \
# --write-properties WriteAnnotations \
# -g ${{ env.RESOURCE_GROUP_NAME }} \
# --app ${{ steps.Infra.outputs.applicationInsightsApplicationId }} \
# --query "apiKey" --output tsv)
# echo "::set-output name=aiKey::$result"
# - name: Annotate deployment
# uses: wictorwilen/application-insights-action@v1
# id: annotation
# with:
# applicationId: ${{ steps.Infra.outputs.applicationInsightsApiAppId }}
# apiKey: ${{ steps.AIKeyGen.outputs.aiKey }}
# releaseName: ${{ github.event_name }}
# message: ${{ github.event.head_commit.message }}
# actor: ${{ github.actor }}
# - name: Remove Temporary API Key For App Insights
# uses: Azure/CLI@v1
# with:
# inlineScript: |
# az config set extension.use_dynamic_install=yes_without_prompt
# az monitor app-insights api-key delete \
# --api-key ${{ steps.Infra.outputs.releaseAnnotationId }} \
# -g ${{ env.RESOURCE_GROUP_NAME }} \
# --app ${{ steps.Infra.outputs.applicationInsightsApplicationId }}