tools/.github/actions/application-deploy/action.yml
2022-02-18 18:07:46 -06:00

51 lines
1.5 KiB
YAML

# File managed by Terraform
# Contents will be overwritten automatically
# To make changes edit the original template in internal-organization
name: 'application-deploy'
description: 'Application deployment'
inputs:
manifest-file:
description: 'Manifest file'
required: true
digest:
description: 'Repository image digest'
required: true
runs:
using: "composite"
steps:
- name: Application deployment
run: |
set -eo pipefail
MANIFEST_FILE="${{ inputs.manifest-file }}"
DIGEST="${{ inputs.digest }}"
function export_json_to_env () {
service_name="$1"
while IFS=$'\t\n' read -r LINE; do
export "${LINE}"
done < <(
<"${MANIFEST_FILE}" jq \
--compact-output \
--raw-output \
--monochrome-output \
--from-file \
<(echo ".[\"${service_name}\"] | to_entries | map(\"\(.key)=\(.value)\") | .[]")
)
}
echo "Deploying ${MANIFEST_FILE}"
mapfile -t services < <(jq -r 'keys[]' "$MANIFEST_FILE")
for service_name in "${services[@]}"; do
export_json_to_env "$service_name"
aws eks update-kubeconfig --name "$eks_cluster_name"
kubectl -n "$eks_cluster_namespace" set image "$k8s_deployment_name" "${k8s_container_name}=${repository_url}@${DIGEST}"
kubectl -n "$eks_cluster_namespace" rollout restart "$k8s_deployment_name"
done
shell: bash