Skip to content

Commit 4cd992f

Browse files
goruhajrbeilke
andauthored
Make ssm-path optional and add kube-version input to skip AWS SSM look up (#75) (#77)
* Make ssm-path optional and add kube-version input to skip AWS SSM look up * fix yaml parsing issue Co-authored-by: Jon Beilke <jrbeilke@gmail.com>
1 parent 2651233 commit 4cd992f

1 file changed

Lines changed: 30 additions & 8 deletions

File tree

action.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ inputs:
2020
required: false
2121
default: helmfile
2222
ssm-path:
23-
required: true
23+
required: false
24+
default: ''
2425
description: SSM path to read environment secrets
2526
operation:
2627
description: Operation with helmfiles. (valid options - `deploy`, `destroy`)
@@ -113,6 +114,10 @@ inputs:
113114
description: "Helmfile version"
114115
required: false
115116
default: "v1.4.3"
117+
kube-version:
118+
description: "Kubernetes version for helm/helmfile rendering (e.g. `1.28`). When provided, skips SSM metadata lookup via chamber."
119+
required: false
120+
default: ""
116121
outputs:
117122
webapp-url:
118123
description: "Web Application url"
@@ -200,7 +205,7 @@ runs:
200205
path: ${{ steps.destination_dir.outputs.name }}
201206

202207
- name: Setup chamber
203-
if: ${{ inputs.operation == 'deploy' }}
208+
if: ${{ inputs.operation == 'deploy' && inputs.ssm-path != '' }}
204209
shell: bash
205210
env:
206211
version: v2.14.1
@@ -227,44 +232,61 @@ runs:
227232
sudo install chamber-${version}-${os}-${arch} /usr/local/bin/chamber
228233
229234
- name: Read platform context
230-
if: ${{ inputs.operation == 'deploy' }}
235+
if: ${{ inputs.operation == 'deploy' && inputs.ssm-path != '' }}
231236
shell: bash
232237
run: |
233238
chamber --verbose export ${{ inputs.ssm-path }}/${{ inputs.environment }} --format yaml --output-file ./platform.yaml
234239
235240
- name: YQ Platform settings
236-
if: ${{ inputs.operation == 'deploy' }}
241+
if: ${{ inputs.operation == 'deploy' && inputs.ssm-path != '' }}
237242
shell: bash
238243
run: |
239244
sudo chmod 777 ./platform.yaml
240245
yq --exit-status --no-colors --inplace eval '{"platform": .}' ./platform.yaml
241246
247+
- name: Create empty platform context
248+
if: ${{ inputs.operation == 'deploy' && inputs.ssm-path == '' }}
249+
shell: bash
250+
run: |
251+
echo 'platform: {}' > ./platform.yaml
252+
242253
- name: Read platform metadata
243-
if: ${{ inputs.operation == 'deploy' }}
254+
if: ${{ inputs.operation == 'deploy' && inputs.ssm-path != '' }}
244255
shell: bash
245256
run: |
246257
chamber --verbose export ${{ inputs.ssm-path }}/_metadata --format yaml --output-file ./_metadata.yaml
247258
248259
- name: YQ Platform settings
249-
if: ${{ inputs.operation == 'deploy' }}
260+
if: ${{ inputs.operation == 'deploy' && inputs.ssm-path != '' }}
250261
shell: bash
251262
id: metadata
252263
run: |
253264
for output in $(yq --exit-status --no-colors eval-all '. | to_entries | map( .key + "=" + .value ) | join("\n")' ./_metadata.yaml); do
254265
echo "${output}" >> $GITHUB_OUTPUT ;
255266
done
256267
268+
- name: Resolve kube version
269+
id: resolved_kube_version
270+
if: ${{ inputs.operation == 'deploy' }}
271+
shell: bash
272+
run: |
273+
kube_version="${{ inputs.kube-version }}"
274+
if [ -z "$kube_version" ] && [ -n "${{ inputs.ssm-path }}" ]; then
275+
kube_version="${{ steps.metadata.outputs.kube_version }}"
276+
fi
277+
echo "value=$kube_version" >> $GITHUB_OUTPUT
278+
257279
- name: Context
258280
if: ${{ inputs.operation == 'deploy' }}
259281
id: arguments
260282
uses: cloudposse/github-action-yaml-config-query@0.1.3
261283
with:
262-
query: .${{ steps.metadata.outputs.kube_version == '' }}
284+
query: .${{ steps.resolved_kube_version.outputs.value == '' }}
263285
config: |-
264286
true:
265287
kube_version: ""
266288
false:
267-
kube_version: --kube-version=${{ steps.metadata.outputs.kube_version }}
289+
kube_version: --kube-version=${{ steps.resolved_kube_version.outputs.value }}
268290
269291
270292
- name: Ensure argocd repo structure

0 commit comments

Comments
 (0)