-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
110 lines (92 loc) · 3.35 KB
/
Copy pathazure-pipelines.yml
File metadata and controls
110 lines (92 loc) · 3.35 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
109
110
trigger:
branches:
include:
- master
pr:
branches:
include:
- master
pool:
vmImage: ubuntu-latest
variables:
NODE_VERSION: 24.x
NPM_CONFIG_CACHE: $(Pipeline.Workspace)/.npm
DOCS_ZIP: $(Build.ArtifactStagingDirectory)/docs.zip
SNAPSHOT_BASE_URL: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net
SNAPSHOT_PATH: DOCS/$(Build.SourceBranch)
steps:
- checkout: self
clean: true
- task: NodeTool@0
displayName: Use Node $(NODE_VERSION)
inputs:
versionSpec: $(NODE_VERSION)
- task: Cache@2
displayName: Cache npm packages
inputs:
key: 'npm | "$(Agent.OS)" | package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(NPM_CONFIG_CACHE)
- script: npm ci
displayName: Install dependencies
- script: npm run build:ci
displayName: Build static export with sitemap
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
- script: npm run build
displayName: Build static export
condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
BASE_URL: /$(SNAPSHOT_PATH)
NEXT_PUBLIC_BASE_URL: /$(SNAPSHOT_PATH)
- script: |
set -euo pipefail
test -f out/index.html
displayName: Verify static export output
- script: |
set -euo pipefail
: "${DEPLOYMENT_SERVER:?DEPLOYMENT_SERVER pipeline variable is required for snapshot upload.}"
: "${DEPLOY_TOKEN:?DEPLOY_TOKEN pipeline variable is required for snapshot upload.}"
cd out
zip -qr "$(DOCS_ZIP)" .
cd -
curl "${DEPLOYMENT_SERVER}/upload" -i -X POST \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer ${DEPLOY_TOKEN}" \
-F "path=$(SNAPSHOT_PATH)" \
-F "storageAccount=babylonsnapshots" \
-F "zip=@$(DOCS_ZIP)"
displayName: Upload static snapshot
condition: succeeded()
env:
DEPLOYMENT_SERVER: $(DEPLOYMENT_SERVER)
DEPLOY_TOKEN: $(DEPLOY_TOKEN)
- script: npm run upload:search -- --clear
displayName: Upload search indexes
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
SEARCH_API_KEY: $(SEARCH_API_KEY)
- task: GitHubComment@0
displayName: Comment PR snapshot location
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
inputs:
gitHubConnection: $(GITHUB_SERVICE_CONNECTION)
repositoryName: $(Build.Repository.Name)
comment: |
Documentation snapshot uploaded.
Snapshot: [$(SNAPSHOT_BASE_URL)/$(SNAPSHOT_PATH)]($(SNAPSHOT_BASE_URL)/$(SNAPSHOT_PATH))
Path: `$(SNAPSHOT_PATH)`
Build: $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)
- script: |
set -euo pipefail
: "${DEPLOYMENT_SERVER:?DEPLOYMENT_SERVER pipeline variable is required for CDN purge.}"
: "${DEPLOY_TOKEN:?DEPLOY_TOKEN pipeline variable is required for CDN purge.}"
curl "${DEPLOYMENT_SERVER}/purge?endpoint=babylonjs-documentation&profileName=babylonjstools" \
-i \
-X POST \
-H "Authorization: Bearer ${DEPLOY_TOKEN}"
displayName: Purge documentation CDN
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
env:
DEPLOYMENT_SERVER: $(DEPLOYMENT_SERVER)
DEPLOY_TOKEN: $(DEPLOY_TOKEN)