forked from build-trust/ockam-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
142 lines (126 loc) · 4.16 KB
/
azure-pipelines.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Ockam-website-$(Date:yyyyMMdd).$(Rev:r)
trigger:
branches:
include:
- master
- stage
- develop
pr: none
pool:
vmImage: 'ubuntu-latest'
variables:
ACCOUNT_NAME: ockamio2$(Build.SourceBranchName)
steps:
- task: NodeTool@0
displayName: 'Install Node.js'
inputs:
versionSpec: '12.x'
- bash: |
if [ ! -z "$SYSTEM_PULLREQUEST_TARGETBRANCH" ]; then
npx commitlint --from $(git rev-parse origin/$SYSTEM_PULLREQUEST_TARGETBRANCH) --to HEAD --verbose
else
npx commitlint --from HEAD~1 --to HEAD --verbose
fi
displayName: 'Lint Commit Messages'
- bash: |
set -ex
./scripts/get-depended-repos.sh
displayName: 'Checkout depended repositories'
- bash: |
set -ex
node ./scripts/fix-frontmatter.js
displayName: 'Fix frontmatter'
- bash: |
set -ex
case $(Build.SourceBranchName) in
master)
export GATSBY_ROOT_URL='https://www.ockam.io'
export GATSBY_STAGE='PRODUCTION'
;;
stage)
export GATSBY_ROOT_URL='https://ockamio2stage.z6.web.core.windows.net'
export GATSBY_STAGE='STAGE'
;;
develop)
export GATSBY_ROOT_URL='https://ockamio2develop.z6.web.core.windows.net'
export GATSBY_STAGE='DEVELOPMENT'
;;
*)
export GATSBY_ROOT_URL='https://fork1ockam2default.z6.web.core.windows.net'
export GATSBY_STAGE='DEVELOPMENT_FORK'
;;
esac
npm ci
npm run build
displayName: 'Install & build site'
env:
GATSBY_ALGOLIA_APP_ID: $(GATSBY_ALGOLIA_APP_ID)
GATSBY_ALGOLIA_ADMIN_API_KEY: $(GATSBY_ALGOLIA_ADMIN_API_KEY)
GATSBY_ALGOLIA_SEARCH_API_KEY: $(GATSBY_ALGOLIA_SEARCH_API_KEY)
GATSBY_GOOGLE_RECAPTCHA_SITEKEY: $(GATSBY_GOOGLE_RECAPTCHA_SITEKEY)
- bash: |
set -ex
rm -f ./public/*.map
rm -f ./public/webpack.stats.json
displayName: 'Remove vulnerabilities'
- bash: |
set -ex
case $(Build.SourceBranchName) in
master)
az storage blob delete-batch \
--account-name $(ACCOUNT_NAME) \
--account-key $(ACCOUNT_KEY_MASTER) \
--source $(CONTAINER)
az storage blob upload-batch \
--account-name $(ACCOUNT_NAME) \
--account-key $(ACCOUNT_KEY_MASTER) \
--source ./public/ \
--destination "https://${ACCOUNT_NAME}.blob.core.windows.net/$(CONTAINER)"
;;
stage)
az storage blob delete-batch \
--account-name $(ACCOUNT_NAME) \
--account-key $(ACCOUNT_KEY_STAGE) \
--source $(CONTAINER)
az storage blob upload-batch \
--account-name $(ACCOUNT_NAME) \
--account-key $(ACCOUNT_KEY_STAGE) \
--source ./public/ \
--destination "https://${ACCOUNT_NAME}.blob.core.windows.net/$(CONTAINER)"
;;
develop)
az storage blob delete-batch \
--account-name $(ACCOUNT_NAME) \
--account-key $(ACCOUNT_KEY_DEV) \
--source $(CONTAINER)
az storage blob upload-batch \
--account-name $(ACCOUNT_NAME) \
--account-key $(ACCOUNT_KEY_DEV) \
--source ./public/ \
--destination "https://${ACCOUNT_NAME}.blob.core.windows.net/$(CONTAINER)"
;;
*)
az storage blob delete-batch \
--account-name $(INTERNAL_ACCOUNT_NAME) \
--account-key $(INTERNAL_ACCOUNT_KEY) \
--source $(CONTAINER)
az storage blob upload-batch \
--account-name $(INTERNAL_ACCOUNT_NAME) \
--account-key $(INTERNAL_ACCOUNT_KEY) \
--source ./public/ \
--destination "https://${INTERNAL_ACCOUNT_NAME}.blob.core.windows.net/$(CONTAINER)"
;;
esac
displayName: 'Deploy to storage'
- bash: |
set -ex
# Login as service principal
az login --service-principal --allow-no-subscriptions -u $(SP_USERNAME) -p $(SP_PASSWORD) --tenant $(TENANT)
# Purge CDN
az cdn endpoint purge \
--resource-group ockam2$(Build.SourceBranchName) \
--name $(CDN_ENDPOINT) \
--profile-name $(CDN_PROFILE) \
--content-paths '/*'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) # only for PRODUCTION
displayName: "Purge CDN"