diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml new file mode 100644 index 0000000..8e3084b --- /dev/null +++ b/.github/workflows/helm.yaml @@ -0,0 +1,59 @@ +name: Reusable Helm +on: + workflow_call: + inputs: + runner: + required: false + description: Runner type + default: ubuntu-latest + type: string + timeoutMinutes: + required: false + description: Maximum minutes before the job is cancelled + default: 40 + type: number + chartsPath: + required: false + description: Directory searched for charts (every directory with a Chart.yaml) + default: .chart + type: string +jobs: + helm: + runs-on: ${{ inputs.runner }} + timeout-minutes: ${{ inputs.timeoutMinutes }} + steps: + - name: Checkout current git repository + uses: actions/checkout@v7 + + - name: Set up Helm + uses: azure/setup-helm@v5 + + - name: Lint and render charts + env: + CHARTS_PATH: ${{ inputs.chartsPath }} + run: | + set -euo pipefail + charts=() + while IFS= read -r chart; do + parent=$(dirname "$chart") + # A chart in /charts/ is a vendored dependency. It is validated + # through its parent, which supplies its values. + if [ "$(basename "$parent")" = charts ] && [ -f "$(dirname "$parent")/Chart.yaml" ]; then + continue + fi + charts+=("$chart") + done < <(find "$CHARTS_PATH" -name Chart.yaml -exec dirname {} \; | sort) + if [ ${#charts[@]} -eq 0 ]; then + echo "::error::No Chart.yaml found under $CHARTS_PATH" + exit 1 + fi + for chart in "${charts[@]}"; do + echo "::group::$chart" + helm dependency build "$chart" + helm lint "$chart" + # Library charts render nothing and make `helm template` fail. + if ! helm show chart "$chart" | grep -q "^type: library"; then + helm template "$chart" > /dev/null + fi + echo "::endgroup::" + done