ci: Add diff pipeline #115
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env: | |
CT_BUILD_ID: '${{ github.run_id }}' | |
name: Chart Testing | |
on: [pull_request] | |
jobs: | |
build: | |
name: lint, install | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up chart-testing | |
uses: helm/chart-testing-action@v2.6.1 | |
- name: Run chart-testing (list-changed) | |
id: list-changed | |
run: | | |
changed=$(ct list-changed --config charts/ct.yaml) | |
if [[ -n "$changed" ]]; then | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Run chart-testing (lint) | |
run: ct lint --debug --config charts/ct.yaml | |
- name: Create kind cluster | |
uses: helm/kind-action@v1.10.0 | |
if: steps.list-changed.outputs.changed == 'true' | |
- name: Run chart-testing (install) | |
run: ct install --debug --config charts/ct.yaml --excluded-charts amazon-eks-pod-identity-webhook,keycloak-config-cli | |
diff: | |
name: check diff | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up chart-testing | |
uses: helm/chart-testing-action@v2.6.1 | |
- name: Run chart-testing (list-changed) | |
id: list-changed | |
run: | | |
changed=$(ct list-changed --config charts/ct.yaml) | |
if [[ -n "$changed" ]]; then | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
echo "changed_list=\"${changed//$'\n'/ }\"" >> "$GITHUB_OUTPUT" | |
fi | |
- name: install helm diff plugin | |
if: steps.list-changed.outputs.changed == 'true' | |
run: | | |
helm env | |
helm plugin install https://github.com/databus23/helm-diff --version 3.9.9 | |
- name: Create kind cluster | |
if: steps.list-changed.outputs.changed == 'true' | |
uses: helm/kind-action@v1.10.0 | |
- name: Run chart-testing (diff) | |
if: steps.list-changed.outputs.changed == 'true' | |
run: | | |
for chart in $changed_list; do | |
chart="${chart#*/}" | |
echo "installing chart: $chart" | |
if helm install --create-namespace --namespace "${chart}" \ | |
"${chart}" "oci://ghcr.io/${{ github.repository_owner }}/charts/$chart"; then | |
helm diff upgrade "${chart}" "charts/${chart}" \ | |
--namespace $chart \ | |
--suppress=CustomResourceDefinition \ | |
--normalize-manifests \ | |
--reset-values \ | |
--suppress-output-line-regex="chart: [0-9]" \ | |
--suppress-output-line-regex="app.kubernetes.io/version: [0-9]" | |
else | |
echo "failed to install chart: $chart" | |
fi | |
done | |
env: | |
changed_list: ${{ steps.list-changed.outputs.changed_list }} |