gitlab-templates/jobs/helm-chart-generate-and-push-to-local-repository.gitlab-ci.yml

24 lines
719 B
YAML

Generate and Push Kubernetes Manifests:
stage: deploy
before_script:
- |
if test ${CI_COMMIT_REF_NAME} = "main"; then
export ENVIRONMENT="prd";
elif test ${CI_COMMIT_REF_NAME} = "staging"; then
export ENVIRONMENT="stg";
else
export ENVIRONMENT="dev";
fi
script:
- helm dependency update ${HELM_CHART_PATH}
- rm -rf .k8s/${ENVIRONMENT}/manifests
- mkdir -p .k8s/${ENVIRONMENT}/manifests
- |
helm template \
${HELM_CHART_NAME} \
${HELM_CHART_PATH} \
--output-dir /tmp/manifests
- mv /tmp/manifests/${HELM_CHART_NAME}/templates/*.yaml .k8s/${ENVIRONMENT}/manifests/
- rm -rf /tmp/manifests/${HELM_CHART_NAME}