Skip to content

Update version to v0.4.2 #559

Update version to v0.4.2

Update version to v0.4.2 #559

name: Auto Chart Lint
env:
DEFAULT_BRANCH: main
on:
workflow_call:
inputs:
ref:
required: true
type: string
workflow_dispatch:
inputs:
ref:
description: 'sha, tag, branch'
required: true
default: main
pull_request:
paths:
- 'charts/**'
jobs:
chart-lint-test:
runs-on: ubuntu-latest
steps:
- name: prepare
id: prepare
run: |
if ${{ inputs.ref != '' }} ; then
echo "trigger by workflow_call"
echo "RUN_REF=${{ inputs.ref }}" >> $GITHUB_ENV
echo "RUN_JUST_LINT_CHART=false" >> $GITHUB_ENV
elif ${{ github.event_name == 'workflow_dispatch' }} ; then
echo "trigger by workflow_dispatch"
echo "RUN_REF=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
echo "RUN_JUST_LINT_CHART=false" >> $GITHUB_ENV
elif ${{ github.event_name == 'pull_request' }} ; then
echo "trigger by pull_request"
echo "RUN_REF=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
echo "RUN_JUST_LINT_CHART=true" >> $GITHUB_ENV
else
echo "error, trigger by unknown event ${{ github.event_name }}"
exit 1
fi
# https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ env.RUN_REF }}
- name: Install yq
run: |
YQ_VERSION=v4.33.1
YQ_BINARY="yq_$(uname | tr 'A-Z' 'a-z')_amd64"
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}.tar.gz -O /tmp/yq.tar.gz
tar -xzf /tmp/yq.tar.gz -C /tmp
sudo mv /tmp/${YQ_BINARY} /usr/bin/yq
sudo chmod +x /usr/bin/yq
yq &>/dev/null || exit 1
- name: Lint Chart
run: |
make chart_package
# trivy
make lint_chart_trivy
# The cached helm binary path is prepended to the PATH environment variable as well as stored in the helm-path output variable
# https://github.com/Azure/setup-helm
- name: Set up Helm
if: ${{ env.RUN_JUST_LINT_CHART == 'false' }}
uses: azure/setup-helm@v3.5
# https://github.com/actions/setup-python
- name: Set up Python
if: ${{ env.RUN_JUST_LINT_CHART == 'false' }}
uses: actions/setup-python@v5.0.0
with:
python-version: 3.8
architecture: x64
# https://github.com/helm/chart-testing-action
# Pre-requisites: A GitHub repo containing a directory with your Helm charts (e.g: charts)
- name: Set up chart-testing
if: ${{ env.RUN_JUST_LINT_CHART == 'false' }}
uses: helm/chart-testing-action@v2.6.1
- name: Run chart-testing (list-changed)
if: ${{ env.RUN_JUST_LINT_CHART == 'false' }}
id: list-changed
run: |
# https://github.com/helm/chart-testing-action/issues/25
# if the default branch is not master , the CLI exits with error
changed=$( ct list-changed --target-branch ${{ env.DEFAULT_BRANCH }} )
if [[ -n "$changed" ]]; then
echo "RUN_CHANGED=true" >> $GITHUB_ENV
fi
# version checking, YAML schema validation on 'Chart.yaml', YAML linting on 'Chart.yaml'
# and 'values.yaml', and maintainer validation
- name: Run chart-testing (lint)
if: ${{ env.RUN_JUST_LINT_CHART == 'false' }}
run: ct lint --debug --target-branch=${{ env.DEFAULT_BRANCH }} --check-version-increment=false
# https://github.com/helm/kind-action
- name: Create Kind cluster
if: ${{ env.RUN_CHANGED == 'true' && env.RUN_JUST_LINT_CHART == 'false' }}
uses: helm/kind-action@v1.8.0
with:
wait: 120s
#kubectl_version: ${{ env.K8S_VERSION }}
# It automatically detects charts changed
- name: Run chart-testing (install)
if: ${{ env.RUN_JUST_LINT_CHART == 'false' }}
run: ct install --debug --target-branch ${{ env.DEFAULT_BRANCH }}
# https://github.com/helm/helm/issues/8036 do below before ct install
# if [ -f "./Chart.lock" ]; then cat ./Chart.lock | grep repository | awk '{print $2}' | while read -r line ; do helm repo add $line $line; done; fi