-
Notifications
You must be signed in to change notification settings - Fork 17
93 lines (80 loc) · 3.12 KB
/
cd.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
name: CD
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed
workflow_dispatch:
jobs:
deployment:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment: dev
runs-on: ubuntu-latest
env:
ARTIFACT_NAME: build
ENVIRONMENT_PREFIX: dev
PROFILE_PATH: profiles
RESOURCE_GROUP: Analytics.DataPlatform.Group
steps:
- uses: actions/checkout@v2
- name: Getting packages to deploy
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci.yml
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}
- id: sql-login
name: Adquiring SQL Access Token
uses: ./.github/actions/azure-resource-login
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
resource-url: "https://database.windows.net"
- id: deploy-report
name: Identifying proposed changes
uses: ./.github/actions/run-sqlpackage
with:
action: 'DeployReport'
sourcepath: $PWD/${ARTIFACT_NAME}
outputpath: $PWD/${ARTIFACT_NAME}/${ENVIRONMENT_PREFIX}
outputfile: deployreport.xml
profile: ${{ github.workspace }}/${{ env.PROFILE_PATH }}/${{ env.ENVIRONMENT_PREFIX }}.profile.xml
authtoken: ${{ steps.sql-login.outputs.token }}
- id: validate-deploy
name: Validating proposed changes
uses: ./.github/actions/validate-sqlpackage
with:
environment: ${{ env.ENVIRONMENT_PREFIX }}
sqlpackage-report: $PWD/${{ env.ARTIFACT_NAME }}/${ENVIRONMENT_PREFIX}/*.xml
outputfile: ${{ env.ENVIRONMENT_PREFIX }}.deployreport.MD
haltonerrors: true
- name: Publishing deployment report
uses: actions/upload-artifact@v2
with:
name: deploy
path: ${{ env.ENVIRONMENT_PREFIX }}.deployreport.MD
- id: mgnt-login
name: Adquiring Azure Resource Management Access Token
uses: ./.github/actions/azure-resource-login
if: steps.validate-deploy.outputs.can-ignore == 'False'
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
resource-url: "https://management.core.windows.net/"
- id: database-snapshot
name: Taking a restore point on target database
uses: ./.github/actions/synapse-snapshot
if: steps.validate-deploy.outputs.can-ignore == 'False'
with:
resource-group: ${{ env.RESOURCE_GROUP }}
profile: ${{ github.workspace }}/${{ env.PROFILE_PATH }}/${{ env.ENVIRONMENT_PREFIX }}.profile.xml
authtoken: ${{ steps.mgnt-login.outputs.token }}
synapse-workspace: true
- id: deploy-target
name: Deploying changes to target
uses: ./.github/actions/run-sqlpackage
if: steps.validate-deploy.outputs.can-ignore == 'False'
with:
action: 'Publish'
sourcepath: $PWD/${ARTIFACT_NAME}
profile: ${{ github.workspace }}/${{ env.PROFILE_PATH }}/${{ env.ENVIRONMENT_PREFIX }}.profile.xml
authtoken: ${{ steps.sql-login.outputs.token }}