fix canary routemap template #402
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Version bump check | |
# Only runs when charts have changed | |
# Check if the version number of changed charts have been bumped | |
on: | |
pull_request: | |
branches: | |
- master | |
paths: | |
- charts/** | |
jobs: | |
# Get the paths for the Helm charts to version check | |
get_paths: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get the paths for Helm charts to version check | |
id: set-matrix | |
run: | | |
# Get paths (in string form) | |
stringPaths=$(find -maxdepth 2 -path './charts/*') | |
# Check paths (length greater than 0) | |
stringPathsLength=$(echo ${#stringPaths}) | |
if (( stringPathsLength == 0 )); | |
then | |
echo "No paths to check" | |
exit 1 | |
fi | |
# Serialize paths into JSON array | |
paths=$(jq -ncR '[inputs]' <<< "$stringPaths") | |
echo $paths | |
# Output serialized paths | |
echo "matrix=$paths" >> $GITHUB_OUTPUT | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
# Version check Helm charts based on paths provided by previous job | |
version_check: | |
name: Version check | |
needs: get_paths | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
version: ${{ fromJson(needs.get_paths.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get modified files in the ${{ matrix.version }} folder | |
id: modified-files | |
uses: tj-actions/changed-files@v35 | |
with: | |
files: ${{ matrix.version }} | |
- name: Run step if any file(s) in the ${{ matrix.version }} folder was modified | |
if: steps.modified-files.outputs.any_modified == 'true' | |
run: | | |
# Remove ./ prefix from raw matrix version (i.e. ./charts/iter8 -> charts/iter8) | |
version=$(echo ${{ matrix.version }} | sed s/".\/"//) | |
# Get chart file | |
chartFile="$version/Chart.yaml" | |
# Get git diff of the Chart.yaml between the master branch and PR branch | |
gitDiff=$(git diff origin/master..HEAD -- $chartFile) | |
echo $gitDiff | |
# Addition in Chart.yaml | |
addChart="+++ b/$add$chartFile" | |
echo $addChart | |
# Addition of version in Chart.yaml | |
addVersion="+version:" | |
echo $addVersion | |
if [[ "$gitDiff" == *"$addChart"* ]] && [[ "$gitDiff" == *$addVersion* ]]; | |
then | |
echo "version in $chartFile has been modified" | |
else | |
echo "version in $chartFile needs to be modified" | |
exit 1 | |
fi |