-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add reusable workflow for Helm Chart
- Loading branch information
Showing
1 changed file
with
134 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
name: _Build and publish Helm Chart | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release: | ||
type: boolean | ||
required: false | ||
default: false | ||
version: | ||
type: string | ||
required: true | ||
default: "0.0.0-dev" | ||
|
||
jobs: | ||
lint-chart: | ||
runs-on: [self-hosted, shared] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
- name: Set up chart-testing | ||
uses: helm/[email protected] | ||
- name: Run chart-testing (lint) | ||
run: ct lint --config .github/ct.yaml --check-version-increment=false | ||
|
||
lint-docs: | ||
runs-on: [self-hosted, shared] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Run helm-docs | ||
env: | ||
HELM_DOCS_VERSION: "1.11.0" | ||
HELM_DOCS_BASE_URL: "https://github.com/norwoodj/helm-docs/releases/download" | ||
run: | | ||
OS=$(uname) | ||
# install helm-docs | ||
curl -sSfL "${HELM_DOCS_BASE_URL}/v${HELM_DOCS_VERSION}/helm-docs_${HELM_DOCS_VERSION}_${OS}_x86_64.tar.gz" | | ||
tar -xzf - helm-docs | ||
# validate docs | ||
./helm-docs | ||
git diff --exit-code | ||
kubeconform-chart: | ||
runs-on: [self-hosted, shared] | ||
strategy: | ||
matrix: | ||
k8s: | ||
- v1.22.4 | ||
- v1.23.0 | ||
- v1.24.0 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Run kubeconform | ||
env: | ||
KUBERNETES_VERSION: ${{ matrix.k8s }} | ||
KUBECONFORM_VERSION: "v0.4.12" | ||
KUBECONFORM_BASE_URL: "https://github.com/yannh/kubeconform/releases/download" | ||
FILENAME_FORMAT: "{kind}-{group}-{version}" | ||
run: | | ||
set -o pipefail | ||
OS=$(uname) | ||
# install kubeconform | ||
curl -sSfL "${KUBECONFORM_BASE_URL}/${KUBECONFORM_VERSION}/kubeconform-${OS}-amd64.tar.gz" | | ||
tar -xzf - kubeconform | ||
# validate changed charts | ||
for chart in ./helm/charts/*/; do | ||
values=$(echo "${chart}" | sed "s/charts/values/g") | ||
echo "Running kubeconform for folder: '${chart}'" | ||
helm dep up "${chart}" && | ||
for value in $(find "${values}" -type f -name "*.yaml"); do | ||
echo -e "▶ Validating ${chart} with values from ${value}" | ||
helm template --kube-version "${KUBERNETES_VERSION#v}" -f "${value}" "${chart}" | | ||
./kubeconform -strict -ignore-missing-schemas -exit-on-error \ | ||
-schema-location default -schema-location 'helm/k8s-crds-schemas/{{ .ResourceKind }}{{ .KindSuffix }}.json' \ | ||
-kubernetes-version "${KUBERNETES_VERSION#v}" -summary -verbose -schema-location default | ||
done | ||
done | ||
publish-chartmuseum-dev: | ||
name: publish-chartmuseum-dev | ||
environment: dev | ||
runs-on: [self-hosted, shared] | ||
needs: [lint-chart, lint-docs, kubeconform-chart] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Add chartmuseum-dev helm repo | ||
run: | | ||
if ! helm plugin list | grep -q push; then | ||
helm plugin install https://github.com/chartmuseum/helm-push.git | ||
fi | ||
helm repo add chartmuseum-dev --username ${{ secrets.CHARTMUSEUM_DEV_USER }} --password ${{ secrets.CHARTMUSEUM_DEV_PASSWORD }} ${{ secrets.CHARTMUSEUM_DEV_URL }} && | ||
helm repo update | ||
- name: Push chart to chartmuseum-dev repo | ||
run: | | ||
for chart in ./helm/charts/*/; do | ||
helm cm-push -f $chart chartmuseum-dev --version ${{ inputs.version }} | ||
done | ||
publish-chartmuseum-prd: | ||
name: publish-chartmuseum-prd | ||
if: inputs.release != false | ||
runs-on: [self-hosted, shared] | ||
needs: [publish-chartmuseum-dev] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Add chartmuseum-prd helm repo | ||
run: | | ||
if ! helm plugin list | grep -q push; then | ||
helm plugin install https://github.com/chartmuseum/helm-push.git | ||
fi | ||
helm repo add chartmuseum-prd --username ${{ secrets.CHARTMUSEUM_PRD_USER }} --password ${{ secrets.CHARTMUSEUM_PRD_PASSWORD }} ${{ secrets.CHARTMUSEUM_PRD_URL }} && | ||
helm repo update | ||
- name: Push chart to chartmuseum-prd repo | ||
run: | | ||
for chart in ./helm/charts/*/; do | ||
helm cm-push $chart chartmuseum-prd --version ${{ inputs.version }} | ||
done |