mirror of
https://github.com/Mintplex-Labs/helm-charts.git
synced 2026-07-01 16:42:09 -04:00
120 lines
3.3 KiB
YAML
120 lines
3.3 KiB
YAML
name: Lint, test and release Helm charts
|
|
|
|
on:
|
|
push:
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
REGISTRY: ghcr.io/mintplex-labs/helm-charts
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with: { fetch-depth: 0 }
|
|
|
|
- uses: azure/setup-helm@v4
|
|
with:
|
|
version: latest
|
|
|
|
- name: Lint
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
for d in charts/*; do
|
|
[[ -f "$d/Chart.yaml" ]] || continue
|
|
echo "==> helm lint $d"
|
|
helm lint "$d"
|
|
done
|
|
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'pull_request' || github.base_ref == github.head_ref
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with: { fetch-depth: 0 }
|
|
|
|
- uses: azure/setup-helm@v4
|
|
with:
|
|
version: latest
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
check-latest: false
|
|
|
|
- name: Set up chart-testing
|
|
uses: helm/chart-testing-action@v2
|
|
|
|
- name: Run chart-testing (list-changed)
|
|
id: list-changed
|
|
run: |
|
|
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
|
|
if [[ -n "$changed" ]]; then
|
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Run chart-testing (lint)
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: ct lint --target-branch ${{ github.event.repository.default_branch }}
|
|
|
|
- name: Create kind cluster
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
uses: helm/kind-action@v1
|
|
|
|
- name: Run chart-testing (install)
|
|
if: steps.list-changed.outputs.changed == 'true'
|
|
run: ct install --target-branch ${{ github.event.repository.default_branch }}
|
|
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
if: github.ref_name == github.event.repository.default_branch
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config user.name "$GITHUB_ACTOR"
|
|
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
|
|
|
- name: Login to GHCR
|
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
|
|
|
|
- name: Publish charts to Helm repo
|
|
uses: helm/chart-releaser-action@v1
|
|
env:
|
|
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
CR_SKIP_EXISTING: "true"
|
|
|
|
- name: Publish charts to Helm registry
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
shopt -s nullglob
|
|
|
|
mkdir -p dist
|
|
for d in charts/*; do
|
|
[[ -f "$d/Chart.yaml" ]] || continue
|
|
echo "==> helm package $d"
|
|
helm package "$d" -d dist
|
|
done
|
|
|
|
for tgz in dist/*.tgz; do
|
|
name="$(basename "$tgz" | sed -E 's/(.*)-([0-9].*)\.tgz/\1/')"
|
|
ver="$(basename "$tgz" | sed -E 's/(.*)-([0-9].*)\.tgz/\2/')"
|
|
repo="oci://${REGISTRY,,}/$name"
|
|
echo "==> $name:$ver"
|
|
if helm show chart "$repo" --version "$ver" >/dev/null 2>&1; then
|
|
echo " already exists, skipping"
|
|
else
|
|
helm push "$tgz" "oci://${REGISTRY,,}"
|
|
fi
|
|
done
|