This repository was archived by the owner on Aug 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipeline-dev.yaml
More file actions
91 lines (80 loc) · 2.8 KB
/
azure-pipeline-dev.yaml
File metadata and controls
91 lines (80 loc) · 2.8 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
---
#------------------------------------------------------------------------------
#
# Filename: azure-pipeline-dev.yml
#
# Description: Deploy web components to DEV path on PROD CDN.
#
# Usage: Run from devops pipeline. Notes:
# - The version is extracted from the package.json file by npm build and the pipeline copy tasks
# - The versioned bundle copy depends on there being a single *.js file in the dist/ directory
#
# Author: Axel Granillo ([email protected])
#
# History:
# 20 June 2023 Axel Granillo Created, Mexico City, Mexico
#-----------------------------------------------------------------------------
pr: none # don't run on PR
trigger:
- develop
variables:
# Azure service connection for storage account access
serviceConnection: 'Prod Azure - NoFrixion Ops'
storageAccountName: 'nofrixioncdn'
bundleName: 'nofrixion-webcomponents.js'
cdnRg: 'nofrixion-ops'
cdnName: 'nofrixioncdn'
cdnProfileName: 'nofrixioncdn'
# A windows agent is required here as the AzureFileCopy@4 task is windows only.
pool:
vmImage: 'ubuntu-latest'
steps:
# these steps set the .js bundle names
- bash: |
# get package version from package.json file
version=$(cat package.json | jq -r '.version')
echo "Version is: $version"
echo "##vso[task.setvariable variable=versionedBundleName;]nofrixion-webcomponents-v${version}.min.js"
displayName: 'set DEV .js bundle names'
- task: NodeTool@0
inputs:
versionSpec: '16.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'npm install'
- script: |
npm run build
displayName: 'npm build'
- script: |
cd dist
mkdir js
cd ..
cp dist/*.js dist/js/$(bundleName)
mv dist/*.js "dist/js/$(versionedBundleName)"
displayName: 'Rename bundles'
# Creates folder structure for blob container
- task: CopyFiles@2
inputs:
sourceFolder: '$(Build.SourcesDirectory)/dist/js'
contents: '**'
targetFolder: '$(Build.ArtifactStagingDirectory)/dev'
displayName: 'Copy js files'
# Copy main .js file to the $web container.
- task: AzureCLI@2
displayName: Copy dev bundle into $web blob container
inputs:
azureSubscription: $(serviceConnection)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az storage blob upload-batch -s "$(Build.ArtifactStagingDirectory)" -d '$web' --account-name "$(storageAccountName)" --overwrite
# Purge CDN endpoint to remove old version
- task: AzureCLI@2
displayName: Purge CDN endpoint
inputs:
azureSubscription: $(serviceConnection)
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
az cdn endpoint purge -g "$(cdnRg)" -n "$(cdnName)" --profile-name "$(cdnProfileName)" --content-paths '/dev/*'