Skip to content

Commit

Permalink
refactor(ci): extract get-all-charts function into workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinWolff committed Sep 19, 2024
1 parent 77c08ea commit cc92b57
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 22 deletions.
5 changes: 0 additions & 5 deletions .github/scripts/generate-sarif-reports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ function createSarifReports() {
chartName="$(basename "$chart")"
mkdir -p reports

if yq -e '.type == "library"' "$chart/Chart.yaml" >/dev/null; then
echo "Skipping library chart '$chart'" >&2
return 0
fi

# shellcheck disable=SC2046
yq -r '.annotations["artifacthub.io/images"]' "$chart/Chart.yaml" |
yq -r '.[] | .image' |
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/get-all-charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Get all Charts

on:
workflow_call:
inputs:
showLibraryCharts:
type: boolean
default: true
outputs:
charts:
description: "All Charts"
value: ${{ jobs.getAllCharts.outputs.charts }}
jobs:
getAllCharts:
runs-on: ubuntu-latest
outputs:
charts: ${{ steps.getCharts.outputs.charts }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- run: pip install yq
- name: Get all charts
id: getCharts
run: |
set -ex
set -o pipefail
(
echo -n charts=
for chart in charts/*; do
# shellcheck disable=SC2016
if [[ -f "$chart/Chart.yaml" ]] && yq --argjson showLibraryCharts '${{ inputs.showLibraryCharts }}' -e '.type != "library" or $showLibraryCharts' "$chart/Chart.yaml" >/dev/null; then
echo "$chart"
else
echo "Skipping library chart: '$chart'" >&2
fi
done | jq -c -Rn '[inputs]'
) | tee -a "$GITHUB_OUTPUT"
20 changes: 3 additions & 17 deletions .github/workflows/scan-for-cves.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@ on:

jobs:
getAllCharts:
runs-on: ubuntu-latest
outputs:
charts: ${{ steps.getCharts.outputs.charts }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4

- name: Get all charts with their images
id: getCharts
run: |
set -ex
set -o pipefail
(
echo -n charts=
for chart in charts/*; do
[[ -f "$chart/Chart.yaml" ]] && echo "$chart"
done | jq -c -Rn '[inputs]'
) | tee -a "$GITHUB_OUTPUT"
uses: ./.github/workflows/get-all-charts.yaml
with:
showLibraryCharts: false

generateSarifReports:
runs-on: ubuntu-latest
Expand Down

0 comments on commit cc92b57

Please sign in to comment.