devops: added configuration and commands for generating and pushing kubernetes manifests in the gitlab ci pipeline.

This commit is contained in:
Rebecca Valente 2025-07-08 12:27:08 -03:00
parent e560622033
commit 6dd9c27813

View File

@ -1,4 +1,5 @@
Generate and Push Kubernetes Manifests: Generate and Push Kubernetes Manifests:
image: rbvtopudding/devops:latest
stage: deploy stage: deploy
before_script: before_script:
- | - |
@ -9,17 +10,26 @@ Generate and Push Kubernetes Manifests:
else else
export ENVIRONMENT="dev"; export ENVIRONMENT="dev";
fi fi
script: script:
- helm dependency update ${HELM_CHART_PATH} - helm dependency update ${HELM_CHART_PATH}
- rm -rf .k8s/${ENVIRONMENT}/manifests - rm -rf .k8s/${ENVIRONMENT}/manifests
- mkdir -p .k8s/${ENVIRONMENT}/manifests - mkdir -p .k8s/${ENVIRONMENT}/manifests
- | - |
helm template \ helm template \
--values ${HELM_CHART_VALUES_PATH} \
${HELM_CHART_EXTRA_OPTS} \
${HELM_CHART_NAME} \ ${HELM_CHART_NAME} \
${HELM_CHART_PATH} \ ${HELM_CHART_PATH} \
--output-dir /tmp/manifests --output-dir /tmp/manifests
- mv /tmp/manifests/${HELM_CHART_NAME}/templates/*.yaml .k8s/${ENVIRONMENT}/manifests/ - mv /tmp/manifests/${HELM_CHART_NAME}/templates/*.yaml .k8s/${ENVIRONMENT}/manifests/
- rm -rf /tmp/manifests/${HELM_CHART_NAME} - rm -rf /tmp/manifests/${HELM_CHART_NAME}
- git config --global user.name "$CI_PROJECT_NAME"
- git config --global user.email "${CI_COMMIT_AUTHOR_EMAIL}"
- |
echo ${CI_PROJECT_URL} | \
sed 's/https:\/\///' | \
xargs -I## git remote add remote_origin "https://oauth2:${COMMIT_TOKEN}@##.git"
- git add --all - git add --all
- git commit -m "[${ENVIRONMENT}] manifests updated, [ci skip]" - git commit -m "[${ENVIRONMENT}] manifests updated, [ci skip]"
- git push -o ci.skip - git push -o ci.skip