Skip to content

Commit

Permalink
fix: refactor variable definition in pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
karlbaumhauer committed Jun 30, 2023
1 parent 2a8e324 commit bd37858
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions .azuredevops/pipelines/templates/push-to-storage-main.template.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
steps:
- bash: |
path=""
path=''
if [[ $(deployment) != "none" ]]; then
# Get version and create version array
version=$(node -p "require('./package.json').version")
echo "Version is $version"
versionArray=($(echo "$version" | tr '.' ' '))
echo "Version array is ${versionArray[@]}"
# Set version paths
echo "Version path is: $version"
patchWildcardPath="x.x.x"
echo "Patch-wildcard path is: $patchWildcardPath"
majorWildcardPath="${versionArray[0]}.x.x"
echo "Major-wildcard path is: $majorWildcardPath"
minorWildcardPath="${versionArray[0]}.${versionArray[1]}.x"
echo "Minor-wildcard path is: $minorWildcardPath"
# If docs-only changes, set paths to storybook
# Set Azure variables to use in templates
if [[ $(deployment) == "docs" ]]; then
path="/storybook"
path='/storybook'
version+=$path
patchWildcardPath+=${path}
echo "Patch-wildcard path is: $patchWildcardPath"
majorWildcardPath+=${path}
echo "Major-wildcard path is: $majorWildcardPath"
minorWildcardPath+=${path}
echo "Minor-wildcard path is: $minorWildcardPath"
fi
# Set Azure variables to use in templates
echo "##vso[task.setvariable variable=version]$version"
echo "Azure Variable <version> is: $(version)"
patchWildcardPath='x.x.x'
if [[ $(deployment) == "docs" ]]; then
patchWildcardPath+=${path}
fi
echo "##vso[task.setvariable variable=patchWildcardPath]$patchWildcardPath"
echo "Azure Variable <patchWildcardPath> is: $(patchWildcardPath)"
majorWildcardPath=${versionArray[0]}
majorWildcardPath+='.x.x'
if [[ $(deployment) == "docs" ]]; then
majorWildcardPath+=${path}
fi
echo "##vso[task.setvariable variable=majorWildcardPath]$majorWildcardPath"
echo "Azure Variable <majorWildcardPath>is: $(majorWildcardPath)"
minorWildcardPath=${versionArray[0]}
minorWildcardPath+=${versionArray[1]}
minorWildcardPath+='.x'
if [[ $(deployment) == "docs" ]]; then
minorWildcardPath+=${path}
fi
echo "##vso[task.setvariable variable=minorWildcardPath]$minorWildcardPath"
echo "Azure Variable <minorWildcardPath>is: $(minorWildcardPath)"
echo "##vso[task.setvariable variable=path]$path"
echo "Azure Variable <path>is: $(path)"
fi
Expand Down

0 comments on commit bd37858

Please sign in to comment.