Skip to content

Merge pull request #285 from luminartech/filestash-helm-chart-update #391

Merge pull request #285 from luminartech/filestash-helm-chart-update

Merge pull request #285 from luminartech/filestash-helm-chart-update #391

name: '[HELM] Package and release'
on:
workflow_dispatch:
inputs:
force-scan-paths:
type: "string"
description: "Helm chart relative dir path(s) to trigger release separated by space for. e.g.: charts/falco charts/monitoring"
required: true
push:
branches:
- main
paths:
# Create a release on version update
- 'charts/**/Chart.yaml'
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
jobs:
package-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Helm Installation
uses: azure/setup-helm@v3
with:
version: v3.10.3
- name: Get list of changed directories
id: changed-files
uses: tj-actions/[email protected]
with:
dir_names: "true"
dir_names_exclude_current_dir: "true"
dir_names_max_depth: 4
files: |
charts/**
- name: Build helm packages and push to registry
run: |
set -xeuo pipefail
echo "${{ steps.changed-files.outputs.all_changed_files }}"
force_scan_paths=(${{ inputs.force-scan-paths }})
if [ ${#force_scan_paths[@]} -gt 0 ]; then
echo "INFO: Doing a manual build and release for helm chart(s): ${{ inputs.force-scan-paths }}"
echo "INFO: This will overwrite old release if exists"
scan_paths=("${force_scan_paths[@]}")
else
scan_paths=(${{ steps.changed-files.outputs.all_changed_files }})
fi
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login -u 'gh-action-bot' --password-stdin ${REGISTRY}
for path in "${scan_paths[@]}"; do
(
cd "${path}"
if [ -f "Chart.yaml" ]; then
echo "Generating helm package for ${path}"
rm -f *.tgz || true
helm dependency update
helm package .
helm push *.tgz oci://${REGISTRY}/luminartech/helm-charts-public
else
echo "WARN: Chart.yaml missing in ${path}. Skipping..."
fi
)
done