From 3ba83a10b7bd9005992232419f9455a887c55aa9 Mon Sep 17 00:00:00 2001 From: Kirill Andrusyak Date: Mon, 3 Jul 2023 22:48:19 +0000 Subject: [PATCH] add pipeline --- pipeline.yaml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 pipeline.yaml diff --git a/pipeline.yaml b/pipeline.yaml new file mode 100644 index 0000000..e09e370 --- /dev/null +++ b/pipeline.yaml @@ -0,0 +1,43 @@ +image: docker:20.10.16 + +variables: + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + DOCKER_TLS_VERIFY: 1 + DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" + +services: + - docker:20.10.16-dind + +stages: + - build + - deploy + +build-job: + stage: build + tags: + - docker + only: + - master + script: + - docker info + - docker build -t docker-registry.dopcore.com/$CI_PROJECT_PATH . + - echo "$CI_REGISTRY_PASSWORD" | docker login docker-registry.dopcore.com -u "$CI_REGISTRY_USER" --password-stdin + - docker push docker-registry.dopcore.com/$CI_PROJECT_PATH + +deploy-job: + stage: deploy + image: dtzar/helm-kubectl:latest + tags: + - docker + only: + - master + script: + - export $(xargs < deploy/.env) + - envsubst < deploy/values.template.yaml > deploy/values.yaml + - "echo 'envs: [' >> deploy/values.yaml" + - kubectl get svc -o=custom-columns=NAME:.metadata.name,PORT:.spec.ports[0].port | grep astra | awk '{ print "{\"name\":\""toupper($1)"\",\"value\":\"http://"$1".default.svc.cluster.local:"$2"\"}," }' >> deploy/values.yaml + - "echo ']' >> deploy/values.yaml" + - kubectl version + - helm upgrade --install $CI_PROJECT_TITLE deploy + - kubectl rollout restart deploy/$CI_PROJECT_TITLE