diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9340773cc818c9ea58086fae534f21fd9d0cee34..dc5d8262cdb4c6d723a37b5c188f7b6af1314dce 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,51 @@ stages: - lint + - build + - deploy flake8: image: "python:latest" stage: lint script: - pip install flake8 - - flake8 \ No newline at end of file + - flake8 + +build-docker-image: + stage: build + only: + - master + image: + name: gitlab-registry.cern.ch/ci-tools/docker-image-builder + entrypoint: [""] + script: + - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json + - /kaniko/executor + --context "${CI_PROJECT_DIR}" + --dockerfile "${CI_PROJECT_DIR}/Dockerfile" + --destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" + +.deploy_template: &deploy_definition + stage: deploy + image: gitlab-registry.cern.ch/paas-tools/openshift-client:latest + +deploy-qa: + <<: *deploy_definition + variables: + APP_NAME: data-updater + NAMESPACE: caimira-data-service-qa + OPENSHIFT_SERVER: https://api.paas.okd.cern.ch + script: + - oc tag --source=docker ${CI_REGISTRY_IMAGE}:latest ${APP_NAME}:latest --token ${QA_DEPLOY_TOKEN} --server=${OPENSHIFT_SERVER} -n ${NAMESPACE} + only: + - master + +deploy-prod: + <<: *deploy_definition + variables: + APP_NAME: data-updater + NAMESPACE: caimira-data-service + OPENSHIFT_SERVER: https://api.paas.okd.cern.ch + script: + - oc tag --source=docker ${CI_REGISTRY_IMAGE}:latest ${APP_NAME}:latest --token ${DEPLOY_TOKEN} --server=${OPENSHIFT_SERVER} -n ${NAMESPACE} + rules: + - if: "$CI_COMMIT_TAG"