From b5d65064ace399d6da16eb8ddb4aefc2bb237377 Mon Sep 17 00:00:00 2001 From: kjeld Schouten-Lebbing Date: Fri, 1 Apr 2022 10:57:40 +0200 Subject: [PATCH] feat(ci): Use bumped-since-last-tag instead of changes since last commit --- .github/actions/collect-changes/action.yaml | 43 +++++++++++++++++++++ .github/workflows/charts-release.yaml | 6 +-- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.github/actions/collect-changes/action.yaml b/.github/actions/collect-changes/action.yaml index 7f53c79d130..c293f0119b1 100644 --- a/.github/actions/collect-changes/action.yaml +++ b/.github/actions/collect-changes/action.yaml @@ -11,6 +11,12 @@ outputs: addedOrModifiedCharts: description: "A list of the charts changed" 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: using: "composite" @@ -43,3 +49,40 @@ runs: CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` ) # Set output to changed 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 diff --git a/.github/workflows/charts-release.yaml b/.github/workflows/charts-release.yaml index 721508715ac..89c4e33d2cf 100644 --- a/.github/workflows/charts-release.yaml +++ b/.github/workflows/charts-release.yaml @@ -69,11 +69,11 @@ jobs: - name: Copy docs to website if: | - steps.collect-changes.outputs.changesDetected == 'true' + steps.collect-changes.outputs.changesDetectedAfterTag == 'true' shell: bash run: | #!/bin/bash - CHARTS=(${{ steps.collect-changes.outputs.addedOrModifiedCharts }}) + CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }}) for i in "${CHARTS[@]}" do IFS='/' read -r -a chart_parts <<< "$i" @@ -95,7 +95,7 @@ jobs: - name: build catalogs if: | - steps.collect-changes.outputs.changesDetected == 'true' + steps.collect-changes.outputs.changesDetectedAfterTag == 'true' run: | pip install yq tools/build-release.sh -p