version: 2.1 orbs: kubernetes: circleci/kubernetes@1.0.0 helm: circleci/helm@2.0.1 jobs: build-push-docker-image: docker: - image: cimg/base:stable environment: TAG: << pipeline.git.tag >> steps: - checkout - add_ssh_keys: fingerprints: - "4c:8e:00:16:94:44:d9:ad:e9:e9:2c:8b:02:d4:8d:7a" - run: cp $HOME/.ssh/id_rsa_4c8e00169444d9ade9e92c8b02d48d7a id_rsa - setup_remote_docker: version: 20.10.12 docker_layer_caching: true - run: docker login rg.fr-par.scw.cloud/lecoffre -u nologin -p $SCW_SECRET_KEY - run: docker build --tag rg.fr-par.scw.cloud/lecoffre/front:$TAG . - run: docker push rg.fr-par.scw.cloud/lecoffre/front:$TAG deploy-docker-image: docker: - image: cimg/base:stable environment: TAG: << pipeline.git.tag >> parameters: env: type: string default: stg steps: - checkout - kubernetes/install-kubeconfig: kubeconfig: KUBECONFIG_DATA - helm/install-helm-client - run: name: Deploy command: > helm upgrade lecoffre-front devops/ -i -f devops/<>.values.yaml -n lecoffre-<> --create-namespace --set lecoffrefront.image.repository='rg.fr-par.scw.cloud/lecoffre/front' --set lecoffrefront.image.tag=$TAG workflows: version: 2 build-and-register-stg: when: and: - equal: [ staging, << pipeline.git.branch >> ] - << pipeline.git.tag >> jobs: - build-push-docker-image: filters: tags: only: /^v.*/ branches: only: staging - deploy-docker-image: env: stg requires: - build-push-docker-image context: - sc-shared-prd filters: tags: only: /^v.*/ branches: ignore: /.*/ build-and-register-ppd: when: and: - equal: [ preprod, << pipeline.git.branch >> ] - << pipeline.git.tag >> jobs: - build-push-docker-image: filters: tags: only: /^v.*/ branches: only: preprod - deploy-docker-image: env: ppd requires: - build-push-docker-image context: - sc-shared-prd filters: tags: only: /^v.*/ branches: ignore: /.*/ build-and-register-prd: when: and: - equal: [ main, << pipeline.git.branch >> ] - << pipeline.git.tag >> jobs: - build-push-docker-image: filters: tags: only: /^v.*/ branches: only: main - deploy-docker-image: env: prd requires: - build-push-docker-image context: - sc-shared-prd filters: tags: only: /^v.*/ branches: ignore: /.*/