variables: CI_PROJECT_DIR: "." CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/mysite DEPLOY: test stages: - build - test - deploy build: only: variables: - $CI_COMMIT_TAG stage: build image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] script: - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG test: only: variables: - $CI_COMMIT_TAG stage: test image: name: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG entrypoint: [""] script: - venv/bin/python manage.py test deploy: only: variables: - $CI_COMMIT_TAG stage: deploy image: name: debian:10 entrypoint: [""] script: - apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null - curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl - chmod +x ./kubectl - mkdir /deploy - for f in $(find k8s -regex '.*\\.ya*ml); do envsubst < $f > "/deploy/$(basename $f)"; done' - ./kubectl apply -f /deploy - ./kubectl rollout status deploy $DEPLOY - ./kubectl exec $(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}') -- python manage.py migrate