|
| 1 | +name: "Test Helm Chart" |
| 2 | +description: "Action to test a Helm chart" |
| 3 | +branding: |
| 4 | + icon: upload-cloud |
| 5 | + color: gray-dark |
| 6 | + |
| 7 | +inputs: |
| 8 | + image-tag: |
| 9 | + description: "The extra parameter image.tag to pass to the helm release" |
| 10 | + required: false |
| 11 | + |
| 12 | +runs: |
| 13 | + using: "composite" |
| 14 | + steps: |
| 15 | + - uses: hoverkraft-tech/ci-github-common/actions/[email protected] |
| 16 | + with: |
| 17 | + # Fetch all history so that we can compare against the target branch |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Check for .tools-version file |
| 21 | + id: check-tools-version |
| 22 | + run: | |
| 23 | + if [[ -f .tools-version ]]; then |
| 24 | + echo "tools-version-exists=true" >> "$GITHUB_OUTPUT" |
| 25 | + else |
| 26 | + echo "tools-version-exists=false" >> "$GITHUB_OUTPUT" |
| 27 | + fi |
| 28 | +
|
| 29 | + - name: Install tools with asdf |
| 30 | + if: steps.check-tools-version.outputs.tools-version-exists == 'true' |
| 31 | + uses: asdf-vm/actions/install@v3 |
| 32 | + |
| 33 | + - name: Check for ct.yaml file |
| 34 | + id: check-ct-yaml |
| 35 | + run: | |
| 36 | + if [[ -f ct.yaml ]]; then |
| 37 | + echo "ct-yaml-exists=true" >> "$GITHUB_OUTPUT" |
| 38 | + else |
| 39 | + echo "ct-yaml-exists=false" >> "$GITHUB_OUTPUT" |
| 40 | + fi |
| 41 | +
|
| 42 | + - uses: actions/setup-python@v5 |
| 43 | + with: |
| 44 | + python-version: '3.12' |
| 45 | + |
| 46 | + - name: Set up chart-testing |
| 47 | + if: steps.check-ct-yaml.outputs.ct-yaml-exists == 'true' |
| 48 | + |
| 49 | + |
| 50 | + - name: Run chart-testing (list-changed) |
| 51 | + id: list-changed |
| 52 | + if: steps.check-ct-yaml.outputs.ct-yaml-exists == 'true' |
| 53 | + run: | |
| 54 | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) |
| 55 | + if [[ -n "$changed" ]]; then |
| 56 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Run chart-testing (lint) |
| 60 | + if: steps.list-changed.outputs.changed == 'true' |
| 61 | + run: ct lint --target-branch ${{ github.event.repository.default_branch }} |
| 62 | + |
| 63 | + - name: Create kind cluster |
| 64 | + if: steps.list-changed.outputs.changed == 'true' |
| 65 | + |
| 66 | + |
| 67 | + - name: Run chart-testing (install) |
| 68 | + if: steps.list-changed.outputs.changed == 'true' |
| 69 | + run: | |
| 70 | + if [[ -n "${{ inputs.image-tag }}" ]]; then |
| 71 | + HELM_EXTRA_ARGS="--set image.tag=${{ inputs.image-tag }}" |
| 72 | + fi |
| 73 | +
|
| 74 | + ct install \ |
| 75 | + --target-branch ${{ github.event.repository.default_branch }} \ |
| 76 | + --helm-extra-args "${HELM_EXTRA_ARGS} --wait" |
0 commit comments