Skip to content

Commit 2261917

Browse files
Consolidate Manifest Deployment Steps in Deploy Template Workflow (#27582)
* Refactored the image and version deployment in the deploy template workflow * check for chart_key * added back env * cleaned up chart_key variable * fail if vets-api or vets-api-parent is missing
1 parent 02b75bb commit 2261917

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

.github/workflows/deploy-template.yml

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -76,42 +76,38 @@ jobs:
7676
path: vsp-infra-application-manifests
7777
ref: refs/heads/main
7878

79-
- name: Update vets-api image and version name in Manifest repo for vets-api-parent charts
79+
- name: Update vets-api image and version name in Manifest repo
8080
env:
8181
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
8282
ECR_REPOSITORY: dsva/${{inputs.ecr_repository}}
8383
run: |
8484
cd vsp-infra-application-manifests/apps/${{inputs.manifests_directory}}
85-
envs=(dev staging)
86-
for env in ${envs[*]};
87-
do
88-
yq e -i '(."vets-api-parent".image.tag) |= "${{ inputs.commit_sha }}"' $env/values.yaml
89-
yq e -i '(."vets-api-parent".web.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
90-
yq e -i '(."vets-api-parent".web.dbMigrate.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
91-
yq e -i '(."vets-api-parent".worker.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
92-
yq e -i '(."vets-api-parent".web.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
93-
yq e -i '(."vets-api-parent".web.dbMigrate.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
94-
yq e -i '(."vets-api-parent".worker.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
95-
done
96-
git diff
9785
98-
- name: Update vets-api image and version name in Manifest repo for parent helm
99-
env:
100-
ECR_REGISTRY: ${{ steps.ecr-login.outputs.registry }}
101-
ECR_REPOSITORY: dsva/${{inputs.ecr_repository}}
102-
run: |
103-
cd vsp-infra-application-manifests/apps/${{inputs.manifests_directory}}
104-
envs=(prod sandbox)
105-
for env in ${envs[*]};
106-
do
107-
yq e -i '(."vets-api".image.tag) |= "${{ inputs.commit_sha }}"' $env/values.yaml
108-
yq e -i '(."vets-api".web.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
109-
yq e -i '(."vets-api".web.dbMigrate.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
110-
yq e -i '(."vets-api".worker.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
111-
yq e -i '(."vets-api".web.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
112-
yq e -i '(."vets-api".web.dbMigrate.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
113-
yq e -i '(."vets-api".worker.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' $env/values.yaml
86+
for env in dev staging prod sandbox; do
87+
has_parent=$(yq e 'has("vets-api-parent")' "$env/values.yaml")
88+
has_vets=$(yq e 'has("vets-api")' "$env/values.yaml")
89+
90+
if [[ "$has_parent" == "true" ]]; then
91+
chart_key="vets-api-parent"
92+
elif [[ "$has_vets" == "true" ]]; then
93+
chart_key="vets-api"
94+
else
95+
echo "Image tag failure. No known chart key found in $env/values.yaml."
96+
exit 1
97+
fi
98+
99+
echo "$env -> $chart_key"
100+
export chart_key
101+
102+
yq e -i '(.[env(chart_key)].image.tag) |= "${{ inputs.commit_sha }}"' "$env/values.yaml"
103+
yq e -i '(.[env(chart_key)].web.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' "$env/values.yaml"
104+
yq e -i '(.[env(chart_key)].web.dbMigrate.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' "$env/values.yaml"
105+
yq e -i '(.[env(chart_key)].worker.envSecrets[] | select(.name=="DD_VERSION").value) |= "${{ inputs.commit_sha }}"' "$env/values.yaml"
106+
yq e -i '(.[env(chart_key)].web.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' "$env/values.yaml"
107+
yq e -i '(.[env(chart_key)].web.dbMigrate.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' "$env/values.yaml"
108+
yq e -i '(.[env(chart_key)].worker.envSecrets[] | select(.name=="DD_GIT_COMMIT_SHA").value) |= "${{ inputs.commit_sha }}"' "$env/values.yaml"
114109
done
110+
115111
git diff
116112
117113
- name: Add and Commit file

0 commit comments

Comments
 (0)