66 - main
77 paths :
88 - ' **/helm/**'
9- workflow_dispatch : # Allow manual triggering
9+ workflow_dispatch :
10+ inputs :
11+ app_name :
12+ description : ' App name to process (e.g., givanz-vvveb)'
13+ required : true
14+ type : string
1015
1116permissions :
1217 contents : write
@@ -37,29 +42,47 @@ jobs:
3742 if : env.SKIP_WORKFLOW != 'true'
3843 id : process-charts
3944 run : |
40- # Find changed files in this commit
41- CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep "helm/" || echo "")
42-
43- if [ -z "$CHANGED_FILES" ]; then
44- echo "helm_exists=false" >> $GITHUB_OUTPUT
45- exit 0
46- fi
47-
48- # Extract unique chart directories from changed files
49- declare -A CHART_DIRS
50-
51- for FILE in $CHANGED_FILES; do
52- APP_NAME=$(echo $FILE | cut -d'/' -f1)
45+ # Determine which charts to process
46+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
47+ # Manual trigger - use the specified app name
48+ APP_NAME="${{ github.event.inputs.app_name }}"
5349 HELM_DIR="${APP_NAME}/helm"
5450
55- if [ -f "${HELM_DIR}/Chart.yaml" ]; then
56- CHART_DIRS["$HELM_DIR"]=1
51+ # Validate that the helm directory exists
52+ if [ ! -d "$HELM_DIR" ]; then
53+ echo "Error: Helm directory not found for app ${APP_NAME}"
54+ echo "helm_exists=false" >> $GITHUB_OUTPUT
55+ exit 1
56+ fi
57+
58+ # Create an associative array with just the specified app
59+ declare -A CHART_DIRS
60+ CHART_DIRS["$HELM_DIR"]=1
61+ else
62+ # Triggered by push - find changed files
63+ CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep "helm/" || echo "")
64+
65+ if [ -z "$CHANGED_FILES" ]; then
66+ echo "helm_exists=false" >> $GITHUB_OUTPUT
67+ exit 0
68+ fi
69+
70+ # Extract unique chart directories from changed files
71+ declare -A CHART_DIRS
72+
73+ for FILE in $CHANGED_FILES; do
74+ APP_NAME=$(echo $FILE | cut -d'/' -f1)
75+ HELM_DIR="${APP_NAME}/helm"
76+
77+ if [ -f "${HELM_DIR}/Chart.yaml" ]; then
78+ CHART_DIRS["$HELM_DIR"]=1
79+ fi
80+ done
81+
82+ if [ ${#CHART_DIRS[@]} -eq 0 ]; then
83+ echo "helm_exists=false" >> $GITHUB_OUTPUT
84+ exit 0
5785 fi
58- done
59-
60- if [ ${#CHART_DIRS[@]} -eq 0 ]; then
61- echo "helm_exists=false" >> $GITHUB_OUTPUT
62- exit 0
6386 fi
6487
6588 # Configure git for commits
@@ -164,12 +187,17 @@ jobs:
164187 done
165188 fi
166189
167- # Always output that helm exists, so publishing can proceed
168- echo "helm_exists=true" >> $GITHUB_OUTPUT
190+ # Always output helm_exists=true when manually running the workflow
191+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
192+ echo "helm_exists=true" >> $GITHUB_OUTPUT
193+ else
194+ # For push events, only set helm_exists=true if we found charts
195+ echo "helm_exists=true" >> $GITHUB_OUTPUT
196+ fi
169197
170198 publish-charts :
171199 needs : increment-versions
172- if : needs.increment-versions.outputs.helm_exists == 'true' || needs.increment-versions.outputs.helm_exists == true
200+ if : needs.increment-versions.outputs.helm_exists == 'true'
173201 runs-on : ubuntu-latest
174202 steps :
175203 - name : Checkout repository (main branch)
@@ -191,29 +219,46 @@ jobs:
191219 - name : Package Helm charts
192220 id : package-charts
193221 run : |
194- # Find changed files in this commit
195- CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep "helm/" || echo "")
196-
197- if [ -z "$CHANGED_FILES" ]; then
198- echo "::warning::No Helm chart changes found, exiting."
199- exit 0
200- fi
201-
202- # Extract unique chart directories from changed files
203- declare -A CHART_DIRS
204-
205- for FILE in $CHANGED_FILES; do
206- APP_NAME=$(echo $FILE | cut -d'/' -f1)
222+ # Determine which charts to process
223+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
224+ # Manual trigger - use the specified app
225+ APP_NAME="${{ github.event.inputs.app_name }}"
207226 HELM_DIR="${APP_NAME}/helm"
208227
209- if [ -f "${HELM_DIR}/Chart.yaml" ]; then
210- CHART_DIRS["$HELM_DIR"]=1
228+ # Validate that the helm directory exists
229+ if [ ! -d "$HELM_DIR" ]; then
230+ echo "::error::Helm directory not found for app ${APP_NAME}"
231+ exit 1
232+ fi
233+
234+ # Create an array with just the specified app
235+ declare -A CHART_DIRS
236+ CHART_DIRS["$HELM_DIR"]=1
237+ else
238+ # Triggered by push - find changed files
239+ CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep "helm/" || echo "")
240+
241+ if [ -z "$CHANGED_FILES" ]; then
242+ echo "::warning::No Helm chart changes found, exiting."
243+ exit 0
244+ fi
245+
246+ # Extract unique chart directories from changed files
247+ declare -A CHART_DIRS
248+
249+ for FILE in $CHANGED_FILES; do
250+ APP_NAME=$(echo $FILE | cut -d'/' -f1)
251+ HELM_DIR="${APP_NAME}/helm"
252+
253+ if [ -f "${HELM_DIR}/Chart.yaml" ]; then
254+ CHART_DIRS["$HELM_DIR"]=1
255+ fi
256+ done
257+
258+ if [ ${#CHART_DIRS[@]} -eq 0 ]; then
259+ echo "::warning::No valid Helm charts found, exiting."
260+ exit 0
211261 fi
212- done
213-
214- if [ ${#CHART_DIRS[@]} -eq 0 ]; then
215- echo "::warning::No valid Helm charts found, exiting."
216- exit 0
217262 fi
218263
219264 # Create directory for packaged charts
0 commit comments