feat(charts): build backend image into chorus repo #530
Workflow file for this run
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
name: Helm Lint and Template Checks | |
on: | |
pull_request: | |
branches: | |
- master | |
jobs: | |
helm-lint-template: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4.2.1 | |
with: | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v45.0.3 | |
- name: Set up Helm | |
uses: azure/setup-helm@v4.2.0 | |
with: | |
version: 'latest' # Use the latest version of Helm | |
- name: Identify modified charts | |
id: modified_charts | |
run: | | |
# Extract the list of changed files from the action output | |
MODIFIED_FILES=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ',' '\n') | |
# Extract the chart directories from the modified files | |
MODIFIED_CHARTS=$(echo "$MODIFIED_FILES" | grep -o 'charts/[^/]*/' | sort -u) | |
# Check if any charts were modified | |
if [ -z "$MODIFIED_CHARTS" ]; then | |
echo "No modified charts found." | |
else | |
echo "MODIFIED_CHARTS=$MODIFIED_CHARTS" >> $GITHUB_ENV | |
fi | |
- name: Add Helm repositories | |
if: env.MODIFIED_CHARTS != '' | |
run: | | |
for chart in ${{ env.MODIFIED_CHARTS }}; do | |
# Extract the repositories from Chart.yaml files | |
REPOS=$(grep 'repository:' $chart/Chart.yaml | awk '{print $2}' | sort -u || true) | |
# Add each repository if REPOS is not empty | |
if [ -n "$REPOS" ]; then | |
for repo in $REPOS; do | |
helm repo add $(basename $repo) $repo | |
done | |
fi | |
done | |
# Update Helm repositories if any were added | |
if [ -n "$REPOS" ]; then | |
helm repo update | |
else | |
echo "No repositories to update." | |
fi | |
- name: Run helm lint | |
if: env.MODIFIED_CHARTS != '' | |
run: | | |
for chart in ${{ env.MODIFIED_CHARTS }}; do | |
helm lint $chart | |
done | |
- name: Fetch missing dependencies | |
if: env.MODIFIED_CHARTS != '' | |
run: | | |
for chart in ${{ env.MODIFIED_CHARTS }}; do | |
# Check if Chart.yaml has dependencies | |
if grep -q 'dependencies:' $chart/Chart.yaml; then | |
helm dependency build $chart | |
else | |
echo "No dependencies to fetch for $chart" | |
fi | |
done | |
- name: Run helm template | |
if: env.MODIFIED_CHARTS != '' | |
run: | | |
for chart in ${{ env.MODIFIED_CHARTS }}; do | |
if [ -f "$chart/values.yaml" ]; then | |
helm template $chart --values $chart/values.yaml | |
else | |
helm template $chart | |
fi | |
done | |