wallet/.gitlab-ci.yml

153 lines
4.3 KiB
YAML
Raw Normal View History

2024-08-31 14:46:20 +00:00
services:
- name: docker:dind
entrypoint: ["env", "-u", "DOCKER_HOST"]
command: ["dockerd-entrypoint.sh"]
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
DOMAIN: ${DOMAIN}
IMAGE_TAG: ${CI_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}
stages:
- build
- deploy
.build-images:
stage: build
before_script:
script:
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CI_REGISTRY}
- echo ${ENV} | base64 -d > .env
- export BR=$(echo $CI_COMMIT_REF_NAME | tr / -)
- docker build --tag ${IMAGE_TAG}:${BR}${CI_COMMIT_SHORT_SHA} --tag ${IMAGE_TAG} .
- docker push ${IMAGE_TAG}:${BR}${CI_COMMIT_SHORT_SHA}
- docker push ${IMAGE_TAG}
.deploy-helm:
stage: deploy
image:
name: dtzar/helm-kubectl
script:
- mkdir -p ~/.kube && echo ${KUBE_CONFIG} | base64 -d > ~/.kube/config
- helm repo add --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASS lpm https://$CI_REGISTRY_HELM/stable
- envsubst < ./.helm/values-rendering.yaml > ./.helm/values.yaml
- export BR=$(echo $CI_COMMIT_REF_NAME | tr / -)
- helm template ./.helm -f ./.helm/values.yaml
- helm upgrade --install -n ${CI_PROJECT_NAMESPACE} ${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME} ./.helm -f ./.helm/values.yaml
--set image.repository=${IMAGE_TAG}
--set image.tag=${BR}${CI_COMMIT_SHORT_SHA}
--set configs.COMMIT_HASH=${CI_COMMIT_SHA}
--set ingress.enabled=true
--set ingress.hosts=${BR}-${CI_PROJECT_NAME}.dev.${DOMAIN}
--set "ingress.tls=true"
- echo ${BR}-${CI_PROJECT_NAME}.${DOMAIN}
.deploy-helm-agent:
stage: deploy
image:
name: dtzar/helm-kubectl
script:
- mkdir -p ~/.kube && echo ${KUBE_CONFIG} | base64 -d > ~/.kube/config
- helm repo add --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASS lpm https://$CI_REGISTRY_HELM/stable
- envsubst < ./.helm/values-agent.yaml > ./.helm/values.yaml
- export BR=$(echo $CI_COMMIT_REF_NAME | tr / -)
- helm template ./.helm -f ./.helm/values.yaml
- helm upgrade --install -n ${CI_PROJECT_NAMESPACE} ${CI_PROJECT_NAME}-${CI_COMMIT_REF_NAME}-agent ./.helm -f ./.helm/values.yaml
--set image.repository=${IMAGE_TAG}
--set image.tag=${BR}${CI_COMMIT_SHORT_SHA}
--set configs.COMMIT_HASH=${CI_COMMIT_SHA}
--set ingress.enabled=false
- echo ${BR}-${CI_PROJECT_NAME}.${DOMAIN}
.deploy-helm-prod:
stage: deploy
image:
name: dtzar/helm-kubectl
script:
- mkdir -p ~/.kube && echo ${KUBE_CONFIG} | base64 -d > ~/.kube/config
- helm repo add --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASS lpm https://$CI_REGISTRY_HELM/stable
- envsubst < ./.helm/values-rendering.yaml > ./.helm/values.yaml
- cat ./.helm/values.yaml
- export BR=$(echo $CI_COMMIT_REF_NAME | tr / -)
- helm template ./.helm -f ./.helm/values.yaml
- sed -i 's/develop/'${BR}${CI_COMMIT_SHORT_SHA}'/' ./.helm/templates/job-migrate.yaml
- helm upgrade --install -n crypto-stories ${CI_PROJECT_NAME} ./.helm -f ./.helm/values.yaml
--set image.repository=${IMAGE_TAG}
--set image.tag=${BR}${CI_COMMIT_SHORT_SHA}
--set configs.COMMIT_HASH=${CI_COMMIT_SHA}
--set ingress.enabled=false
--set ingress.hosts=custodial.cryptopay.is
--set "ingress.tls=false"
- echo trc.cryptopay.is
build-images-develop:
extends: .build-images
environment: develop
tags:
- k8s-runner01
only:
- develop
build-images-feature:
extends: .build-images
environment: feature
tags:
- k8s-runner01
only:
- /^feature/
build-images-production:
extends: .build-images
environment: production
tags:
- k8s-runner01
only:
- rc
- tags
deploy-develop:
extends: .deploy-helm
environment: develop
tags:
- k8s-runner01
only:
- develop
when: manual
deploy-develop-agent:
extends: .deploy-helm-agent
environment: develop
tags:
- k8s-runner01
only:
- develop
when: manual
deploy-feature:
extends: .deploy-helm
environment: feature
tags:
- k8s-runner01
only:
- /^feature/
when: manual
deploy-feature-agent:
extends: .deploy-helm-agent
environment: feature
tags:
- k8s-runner01
only:
- /^feature/
when: manual
deploy-production:
extends: .deploy-helm-prod
environment: production
tags:
- k8s-runner01
only:
- rc
- tags
when: manual