-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
azure-pipelines-sb.yml
87 lines (77 loc) · 2.78 KB
/
azure-pipelines-sb.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
# Node.js with React
# Build a Node.js project that uses React.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
pool:
vmImage: "ubuntu-latest"
steps:
- task: Bash@3
displayName: Generate build number tag if required
inputs:
targetType: "inline"
script: |
if [ $(Build.SourceBranch) != "refs/heads/master" ]
then
# Lowercase
tag=$(sed 's/.*/\L&/' <<< $(Build.SourceBranchName))
# Replace non alpha-numeric to -
tag=$(sed 's/[^0-9a-z\-]/-/g' <<< $tag)
# Set the build number in DevOps
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber).0-$tag"
else
echo "##vso[build.updatebuildnumber]$(Build.BuildNumber).0"
fi
failOnStderr: true
- task: Bash@3
displayName: Update version number in package.json
inputs:
targetType: "inline"
script: 'sed -i $"s/\"version\": \"[^\"]*\"/\"version\": \"$(Build.BuildNumber)\"/g" .storybook/package.json'
env:
GITVERSIONNUMBER: $(Build.BuildNumber)
- task: Bash@3
displayName: Update version number in react-spaces-storybook package.json
inputs:
targetType: "inline"
script: sed -i "s/0.2.2/$GITVERSIONNUMBER/g" .storybook/package.json
env:
GITVERSIONNUMBER: $(GitVersion.SemVer)
- task: NodeTool@0
inputs:
versionSpec: "20.x"
checkLatest: true
displayName: "Install Node.js"
- task: Cache@2
displayName: Cache node_modules
inputs:
key: 'npm | "$(Agent.OS)" | $(Build.SourcesDirectory)/package-lock.json'
path: $(Build.SourcesDirectory)/node_modules
cacheHitVar: CACHE_RESTORED
- task: Npm@1
displayName: "Install the dependencies"
inputs:
command: custom
verbose: false
customCommand: "ci"
condition: ne(variables.CACHE_RESTORED, 'true')
- script: |
npm test
displayName: "Run tests"
- script: |
npm run build-storybook
displayName: "Build storybook"
- task: CopyFiles@2
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Move storybook package json
inputs:
SourceFolder: ".storybook"
Contents: "package.json"
TargetFolder: "./storybook-static"
OverWrite: true
- task: Npm@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Publish react-spaces-storybook
inputs:
command: "publish"
workingDir: "storybook-static"
publishEndpoint: "NPM"