12
12
workflow_dispatch :
13
13
14
14
jobs :
15
+ find-examples :
16
+ runs-on : ubuntu-latest
17
+ outputs :
18
+ examples : ${{ steps.set-matrix.outputs.examples }}
19
+ steps :
20
+ - name : Checkout code
21
+ uses : actions/checkout@v4
22
+
23
+ - name : Find all examples and create matrix
24
+ id : set-matrix
25
+ run : |
26
+ # Find all example directories
27
+ ALL_EXAMPLES=$(find charts/ggscout/examples -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
28
+
29
+ # Create JSON array for GitHub Actions matrix
30
+ echo "examples=$(echo "$ALL_EXAMPLES" | jq -R -s -c 'split("\n") | map(select(length > 0))')" >> $GITHUB_OUTPUT
31
+
32
+ echo "Found examples: $ALL_EXAMPLES"
33
+
34
+ lint-examples :
35
+ needs : find-examples
36
+ runs-on : ubuntu-latest
37
+ strategy :
38
+ # Run all examples in parallel
39
+ fail-fast : false
40
+ matrix :
41
+ example : ${{ fromJson(needs.find-examples.outputs.examples) }}
42
+
43
+ steps :
44
+ - name : Checkout code
45
+ uses : actions/checkout@v4
46
+
47
+ - name : Set up Helm
48
+ uses : azure/setup-helm@v3
49
+ with :
50
+ version : ' latest'
51
+
52
+ - name : Install yq
53
+ run : |
54
+ sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
55
+ sudo chmod +x /usr/bin/yq
56
+
57
+ - name : Lint chart example - ${{ matrix.example }}
58
+ run : |
59
+ echo "🔍 Linting example: ${{ matrix.example }}"
60
+
61
+ # Create values-ci.yaml for linting
62
+ echo "Creating values-ci.yaml for ${{ matrix.example }}"
63
+ cp "charts/ggscout/examples/${{ matrix.example }}/values.yaml" "charts/ggscout/examples/${{ matrix.example }}/values-ci.yaml"
64
+
65
+ # Check if secret.yaml exists and apply values to values-ci.yaml
66
+ if [ -f "charts/ggscout/examples/${{ matrix.example }}/secret.yaml" ]; then
67
+ echo "Found secret.yaml, using it for values replacement"
68
+
69
+ # Create a temporary file to store environment variables
70
+ ENV_FILE="charts/ggscout/examples/${{ matrix.example }}/.env.tmp"
71
+ touch $ENV_FILE
72
+
73
+ # Extract keys and values from secret.yaml and write to env file
74
+ yq '.stringData | to_entries | .[] | .key + "=" + .value' "charts/ggscout/examples/${{ matrix.example }}/secret.yaml" > $ENV_FILE
75
+
76
+ # Process values-ci.yaml and replace ${VAR} patterns with actual values from secret.yaml
77
+ # Read env file line by line
78
+ while IFS= read -r line; do
79
+ # Extract key and value
80
+ KEY=$(echo $line | cut -d= -f1)
81
+ VALUE=$(echo $line | cut -d= -f2-)
82
+ # Remove quotes if present
83
+ VALUE="${VALUE%\"}"
84
+ VALUE="${VALUE#\"}"
85
+ VALUE="${VALUE%\'}"
86
+ VALUE="${VALUE#\'}"
87
+
88
+ # Replace ${KEY} with VALUE in values-ci.yaml
89
+ sed -i.bak "s|\${$KEY}|$VALUE|g" "charts/ggscout/examples/${{ matrix.example }}/values-ci.yaml"
90
+ rm "charts/ggscout/examples/${{ matrix.example }}/values-ci.yaml.bak"
91
+ done < $ENV_FILE
92
+
93
+ # Remove temporary env file
94
+ rm $ENV_FILE
95
+ fi
96
+
97
+ # Run helm lint
98
+ if ! helm lint charts/ggscout -f "charts/ggscout/examples/${{ matrix.example }}/values-ci.yaml"; then
99
+ echo "❌ Helm lint failed for ${{ matrix.example }}"
100
+ exit 1
101
+ else
102
+ echo "✅ Helm lint passed for ${{ matrix.example }}"
103
+ fi
104
+
105
+ # Clean up the temporary values-ci.yaml file
106
+ rm "charts/ggscout/examples/${{ matrix.example }}/values-ci.yaml"
107
+
15
108
validate-examples :
109
+ needs : lint-examples
16
110
runs-on : ubuntu-latest
17
111
18
112
strategy :
@@ -350,4 +444,4 @@ jobs:
350
444
351
445
for example in $DIRS; do
352
446
echo "|$example|✅ Passed with job completion|" >> $GITHUB_STEP_SUMMARY
353
- done
447
+ done
0 commit comments