feat(ci): Use bumped-since-last-tag instead of changes since last commit

This commit is contained in:
kjeld Schouten-Lebbing 2022-04-01 10:57:40 +02:00
parent 7adf474ac2
commit b5d65064ac
No known key found for this signature in database
GPG Key ID: 4CDAD4A532BC1EDB
2 changed files with 46 additions and 3 deletions

View File

@ -11,6 +11,12 @@ outputs:
addedOrModifiedCharts: addedOrModifiedCharts:
description: "A list of the charts changed" description: "A list of the charts changed"
value: ${{ steps.filter-charts.outputs.addedOrModified }} value: ${{ steps.filter-charts.outputs.addedOrModified }}
changesDetectedAfterTag:
description: "Flag if there are any modified and bump Charts after last tag"
value: ${{ steps.filter-bumped-charts.outputs.changesDetectedAfterTag }}
modifiedChartsAfterTag:
description: "A list of the charts changed and bumped after last Tag"
value: ${{ steps.filter-bumped-charts.outputs.modifiedChartsAfterTag }}
runs: runs:
using: "composite" using: "composite"
@ -43,3 +49,40 @@ runs:
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` ) CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` )
# Set output to changed charts # Set output to changed charts
printf "::set-output name=addedOrModified::%s\n" "${CHARTS[*]}" printf "::set-output name=addedOrModified::%s\n" "${CHARTS[*]}"
- name: Collect changed charts
id: filter-bumped-charts
shell: bash
run: |
local repo_root
repo_root=$(git rev-parse --show-toplevel)
pushd "$repo_root" > /dev/null
echo 'Looking up latest tag...'
local latest_tag
latest_tag=$(lookup_latest_tag)
echo "Discovering changed charts since '$latest_tag'..."
local changed_charts=()
readarray -t changed_charts <<< "$(lookup_changed_charts "$latest_tag")"
if [ ${#changed_charts[@]} -eq 0 ]; then
echo "No Changed Charts detected since latest tag..."
printf "::set-output name=changesDetectedAfterTag::%s\n" "false"
else
echo "Changed Charts detected since latest tag, parsing..."
printf "::set-output name=changesDetectedAfterTag::%s\n" "true"
CHARTS=()
# Get only the chart paths
for CHARTPATH in "${changed_charts[@]}"
do
IFS='/' read -r -a path_parts <<< "${CHARTPATH}"
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
done
# Remove duplicates
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` )
# Set output to changed charts
printf "::set-output name=modifiedChartsAfterTag::%s\n" "${CHARTS[*]}"
fi

View File

@ -69,11 +69,11 @@ jobs:
- name: Copy docs to website - name: Copy docs to website
if: | if: |
steps.collect-changes.outputs.changesDetected == 'true' steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
shell: bash shell: bash
run: | run: |
#!/bin/bash #!/bin/bash
CHARTS=(${{ steps.collect-changes.outputs.addedOrModifiedCharts }}) CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }})
for i in "${CHARTS[@]}" for i in "${CHARTS[@]}"
do do
IFS='/' read -r -a chart_parts <<< "$i" IFS='/' read -r -a chart_parts <<< "$i"
@ -95,7 +95,7 @@ jobs:
- name: build catalogs - name: build catalogs
if: | if: |
steps.collect-changes.outputs.changesDetected == 'true' steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: | run: |
pip install yq pip install yq
tools/build-release.sh -p tools/build-release.sh -p