|
1 | 1 | name: Helm Chart CI/CD |
2 | 2 | permissions: read-all |
3 | 3 | # [Deploying/Linting for] [<chart>/all charts] in [dev/test/prod/all environments] |
4 | | -run-name: ${{ inputs.run_cd && 'Deploying ' || 'Linting for' }} ${{ github.event_name =='workflow_dispatch' && (inputs.chart == 'all' && 'all charts' || inputs.chart) || 'changed files'}} in ${{ inputs.environment == 'all' && 'all environments' || inputs.environment }} |
| 4 | +run-name: ${{ ((inputs.run_cd && github.event_name == 'workflow_dispatch') || github.event_name == 'push') && 'Deploying ' || 'Linting for' }} ${{ github.event_name =='workflow_dispatch' && (inputs.chart == 'all' && 'all charts' || inputs.chart) || 'changed files'}} in ${{ inputs.environment == 'all' && 'all environments' || inputs.environment }} |
5 | 5 | on: |
6 | 6 | push: |
7 | 7 | branches: [main] |
@@ -75,16 +75,19 @@ jobs: |
75 | 75 | # Default environments |
76 | 76 | environments=("${{ inputs.environment }}") |
77 | 77 |
|
78 | | - # Handle "all" case |
79 | | - if [[ "${{ inputs.environment }}" == "all" ]]; then |
| 78 | + # If "all" is selected or we are linting a PR, we include all environments |
| 79 | + if [[ "${{ inputs.environment }}" == "all" || "${{ github.event_name }}" == "pull_request" ]]; then |
| 80 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 81 | + echo "Linting this PR. All environments will be included." >> $GITHUB_STEP_SUMMARY |
| 82 | + fi |
80 | 83 | environments=("dev" "test" "prod") |
81 | 84 | fi |
82 | 85 |
|
83 | 86 | # Convert to compact JSON array |
84 | 87 | environments_json=$(printf '%s\n' "${environments[@]}" | jq -R . | jq -s -c .) |
85 | 88 |
|
86 | 89 | echo "environments=${environments_json}" >> $GITHUB_OUTPUT |
87 | | - echo -e "#Environments to process: \n```json\n${environments_json}\n```" >> $GITHUB_STEP_SUMMARY |
| 90 | + echo -e "#Environments to process: \n\`\`\`json\n${environments_json}\n\`\`\`" >> $GITHUB_STEP_SUMMARY |
88 | 91 |
|
89 | 92 | - name: Set matrix for changed charts |
90 | 93 | id: set-chart-matrix |
@@ -132,23 +135,28 @@ jobs: |
132 | 135 | fi |
133 | 136 | fi |
134 | 137 |
|
135 | | - # If no charts selected, default to all |
| 138 | + # If no charts selected, skip the rest of the steps |
136 | 139 | if [[ ${#charts[@]} -eq 0 ]]; then |
137 | | - for chart_name in "${!chart_dirs[@]}"; do |
138 | | - charts+=("{\"name\":\"$chart_name\",\"dir\":\"${chart_dirs[$chart_name]}\"}") |
139 | | - done |
| 140 | + echo "No charts eligible for processing." >> $GITHUB_STEP_SUMMARY |
| 141 | + echo "charts=[]" >> $GITHUB_OUTPUT |
| 142 | + exit 0 |
140 | 143 | fi |
141 | 144 |
|
142 | 145 | # Convert to JSON array |
143 | 146 | charts_json=$(printf '%s\n' "${charts[@]}" | jq -s -c '.') |
144 | 147 |
|
145 | 148 | echo "charts=${charts_json}" >> $GITHUB_OUTPUT |
146 | | - echo -e "#Charts to process: \n```json\n${charts_json}\n```" >> $GITHUB_STEP_SUMMARY |
| 149 | + echo -e "#Charts to process: \n\`\`\`json\n${charts_json}\n\`\`\`" >> $GITHUB_STEP_SUMMARY |
147 | 150 |
|
148 | 151 | lint-and-test: |
149 | 152 | needs: setup |
150 | 153 | runs-on: ubuntu-latest |
| 154 | + if: needs.setup.outputs.charts != '[]' |
| 155 | + concurrency: |
| 156 | + group: ${{ github.ref }} |
| 157 | + cancel-in-progress: true |
151 | 158 | strategy: |
| 159 | + fail-fast: false |
152 | 160 | matrix: |
153 | 161 | chart: ${{ fromJson(needs.setup.outputs.charts) }} |
154 | 162 | environment: ${{ fromJson(needs.setup.outputs.environments) }} |
|
0 commit comments