From b0c97f07d747ca6f820db7020d56e5604ca8279b Mon Sep 17 00:00:00 2001 From: Chris Werner Rau Date: Tue, 19 Nov 2024 13:31:19 +0100 Subject: [PATCH] fix(ci): correctly run commands (#1240) fix(ci): source linuxbrew env to make trivy available --- .github/workflows/check-licenses.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-licenses.yaml b/.github/workflows/check-licenses.yaml index 86b2bb463..6e51a8606 100644 --- a/.github/workflows/check-licenses.yaml +++ b/.github/workflows/check-licenses.yaml @@ -23,7 +23,9 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - run: pip install yq - run: /home/linuxbrew/.linuxbrew/bin/brew install trivy - - run: ./.github/scripts/scan-for-licenses.sh ${{ needs.getChangedChart.outputs.chart }} + - run: | + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + ./.github/scripts/scan-for-licenses.sh ${{ needs.getChangedChart.outputs.chart }} check-licenses-list: name: check licenses from list runs-on: ubuntu-latest @@ -34,8 +36,10 @@ jobs: - env: chart: ${{ needs.getChangedChart.outputs.chart }} run: | + set -ex + set -o pipefail # shellcheck disable=SC2016 - if missingImages="$(yq -r -e -c --argjson usedImages "$(cat "${chart?}/Chart.yaml" .github/image_licenses.yaml | yq -r '.annotations["artifacthub.io/images"]' | yq -r -c 'map(.image | split(":")[0]) | unique')" '$usedImages - (.licenses | keys) | if length == 0 then false else . end')"; then + if missingImages="$(yq -r -e -c --argjson usedImages "$(yq -r '.annotations["artifacthub.io/images"]' "charts/${chart?}/Chart.yaml" | yq -r -c 'map(.image | split(":")[0]) | unique')" '$usedImages - (.licenses | keys) | if length == 0 then false else . end' .github/image_licenses.yaml)"; then echo "The following images have no license, please review:" echo "$missingImages" | yq -r 'map(" - " + .)[]' exit 1