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

31 lines
880 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}
- git add --all
- git commit -m "[${ENVIRONMENT}] manifests updated, [ci skip]"
- git push -o ci.skip
only:
- main
- staging
- develop