Skip to content

fix: fix templates

fix: fix templates #90

Workflow file for this run

name: CI - Helm Lint
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- 'charts/**'
- '!charts/**/README.md'
jobs:
helm-lint:
runs-on: 'ubuntu-latest'
defaults:
run:
shell: sh
steps:
- name: "Checkout current PR"
uses: actions/checkout@v3
- name: "Checkout main branch"
uses: actions/checkout@v4
with:
ref: main
path: main
- name: "Install Helm"
uses: azure/setup-helm@v4
with:
version: v3.7.0
- name: "Install gomplate binary"
run: |
wget -qO gomplate https://github.com/hairyhenderson/gomplate/releases/download/v3.9.0/gomplate_linux-amd64-slim
chmod u+x gomplate
- name: "Get Helm Charts changed"
uses: jitterbit/get-changed-files@v1
id: updated_files
with:
format: csv
token: ${{ secrets.GITHUB_TOKEN }}
- name: "Dump updated Helm Charts folders and validate semantic versioning"
run: |
echo "${{ steps.updated_files.outputs.all }}" | tr "," "\n" | awk -F\/ '/^charts/ && /\// && !/^\./ {print $2}' | sort | uniq > changed_charts
while read chart; do
# Get Chart version in the current PR branch
version=$(awk -F\: '/^version:/ {print $(NF)}' charts/${chart}/Chart.yaml|tr -d " ")
# Get Chart version in main branch if the chart exists
if [[ -f main/charts/${chart}/Chart.yaml ]]; then
version_main=$(awk -F\: '/^version:/ {print $(NF)}' main/charts/${chart}/Chart.yaml|tr -d " ")
# Calculate valid next versions
major_main=$(echo ${version_main}| awk -F. '{print $1}')
major_main_next=$(echo ${major_main} + 1 | bc).0.0
minor_main=$(echo ${version_main}| awk -F. '{print $2}')
minor_main_next=${major_main}.$(echo ${minor_main} + 1 | bc).0
patch_main=$(echo ${version_main}| awk -F. '{print $3}')
patch_main_next=${major_main}.${minor_main}.$(echo ${patch_main} + 1 | bc)
# Chart version in current PR must be one of the valid versions
set +e
echo "${major_main_next},${minor_main_next},${patch_main_next}" | tr "," "\n" | grep -w "${version}" > /dev/null
rc=$?
set -e
if [ ${rc} -ne 0 ]; then
echo "Version specified in charts/${chart}/Chart.yaml is ${version}, which does not follow semantic versioning."
echo "It must be a valid next semantic version. For this case, valid semantic versions are:"
echo ""
echo "- Next valid patch: ${patch_main_next}"
echo "- Next valid minor: ${minor_main_next}"
echo "- Next valid major: ${major_main_next}"
exit 1
fi
else
echo "Chart ${chart} does not exist in branch main, hence skipping semantic version check."
fi
done <<EOF
$(cat changed_charts)
EOF
- name: "Helm Lint"
run: |
while read chart; do
if [ -d ${chart} ]; then
helm lint "./charts/${chart}/" || false
else
echo "Skipping charts/${chart} as it seems it has been deleted."
fi
done <<EOF
$(cat changed_charts)
EOF
- name: "Generate README.md from template docs/README.tpl to update list of Charts"
run: |
${GITHUB_WORKSPACE}/gomplate -f ${GITHUB_WORKSPACE}/docs/README.tpl -o ${GITHUB_WORKSPACE}/README.md
- name: "Commit updated README.md to the branch if changed"
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "ci(release): update chart list"
file_pattern: README.md