Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.63 KiB
Newer Older
cyril.cros's avatar
cyril.cros committed
---
cyril.cros's avatar
cyril.cros committed
variables:
cyril.cros's avatar
cyril.cros committed
  S3_ENDPOINT: "https://s3.embl.de"
  S3_BUCKET: "annelids"
  JBROWSE_HOSTNAME: "genomes-testing.arendt.embl.de"
  RELEASE_LABEL: "testing"
  INGRESS_CLASS: "internal-users"
cyril.cros's avatar
cyril.cros committed

cyril.cros's avatar
cyril.cros committed
stages:
cyril.cros's avatar
cyril.cros committed
  - build
  - deploy
  - clean
cyril.cros's avatar
cyril.cros committed

cyril.cros's avatar
cyril.cros committed
s3_access_test:
cyril.cros's avatar
cyril.cros committed
  stage: deploy
cyril.cros's avatar
cyril.cros committed
  image: minio/mc
  rules:
    - when: always  # TODO change where necessary
  allow_failure: true  # Don't care if we are not uploading anything yet
  before_script:
    - mc alias set genomes $S3_ENDPOINT $S3_ACCESS_KEY $S3_SECRET_KEY
  script:
    - mc ls genomes/$S3_BUCKET

cyril.cros's avatar
cyril.cros committed
cluster_access_test:
cyril.cros's avatar
cyril.cros committed
  stage: deploy
  image: line/kubectl-kustomize:1.30.1-5.4.2
cyril.cros's avatar
cyril.cros committed
  before_script:
    - echo $KUBECONFIG | base64 -d > /tmp/kubeconf
    - export KUBECONFIG=/tmp/kubeconf
  script:
    - kubectl config current-context
cyril.cros's avatar
cyril.cros committed
    - when: always  # TODO change where necessary
build_nginx_with_jbrowse_config_file:
  stage: build
  image: gcr.io/kaniko-project/executor:debug-v0.21.0
  before_script:
    # yamllint disable-line rule:line-length
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
  script:
    - /kaniko/executor --cache=true --context $CI_PROJECT_DIR/image
      --dockerfile $CI_PROJECT_DIR/image/Dockerfile
      --destination $CI_REGISTRY_IMAGE:jbrowse2-$CI_COMMIT_SHORT_SHA
    - echo "Destination follows"
    - echo $CI_REGISTRY_IMAGE:jbrowse2-$CI_COMMIT_SHORT_SHA
cyril.cros's avatar
cyril.cros committed

cyril.cros's avatar
cyril.cros committed
export_advanced_artifacts_via_inception:
cyril.cros's avatar
cyril.cros committed
  stage: build
cyril.cros's avatar
cyril.cros committed
  image: $CI_REGISTRY_IMAGE:jbrowse2-$CI_COMMIT_SHORT_SHA
cyril.cros's avatar
cyril.cros committed
  needs:
    - build_nginx_with_jbrowse_config_file
  script:
    - cp /usr/share/nginx/html/config.json image/config.json
cyril.cros's avatar
cyril.cros committed
  artifacts:
    paths:
      - image/config.json
cyril.cros's avatar
cyril.cros committed

cyril.cros's avatar
cyril.cros committed
deploy_to_k8s:
  stage: deploy
  image: dtzar/helm-kubectl:3.8.2
cyril.cros's avatar
cyril.cros committed
  needs:
    - cluster_access_test
    - s3_access_test
    - build_nginx_with_jbrowse_config_file
cyril.cros's avatar
cyril.cros committed
  before_script:
cyril.cros's avatar
cyril.cros committed
    - echo $KUBECONFIG | base64 -d > /tmp/kubeconf
    - export KUBECONFIG=/tmp/kubeconf
cyril.cros's avatar
cyril.cros committed
  script:
cyril.cros's avatar
cyril.cros committed
    - echo "You are on branch $CI_COMMIT_REF_NAME"
cyril.cros's avatar
cyril.cros committed
    - envsubst < deployment/jbrowse2-dep.yml > deployment/jbrowse2-dep.yaml
    - cat deployment/jbrowse2-dep.yaml
    - kubectl apply -k deployment
    - kubectl -n $NS rollout restart deployment/jbrowse2-$RELEASE_LABEL
    - kubectl -n $NS wait --for=condition=available
      --timeout=60s deploy/jbrowse2-$RELEASE_LABEL
    - kubectl -n $NS rollout status deployment/jbrowse2-$RELEASE_LABEL
  rules:
cyril.cros's avatar
cyril.cros committed
    - if: '$CI_COMMIT_REF_NAME  == "main"'
      variables:
        JBROWSE_HOSTNAME: "genomes.arendt.embl.de"
        RELEASE_LABEL: "prod"
        INGRESS_CLASS: "external-users"
      when: on_success
    - if: '$CI_COMMIT_REF_NAME  == "dev"'
      variables:
        JBROWSE_HOSTNAME: "genomes-dev.arendt.embl.de"
        RELEASE_LABEL: "dev"
        INGRESS_CLASS: "internal-users"
      when: on_success
cyril.cros's avatar
cyril.cros committed
    - when: on_success
cyril.cros's avatar
cyril.cros committed

cyril.cros's avatar
cyril.cros committed
clean_up_k8s_deployment:
cyril.cros's avatar
cyril.cros committed
  stage: clean
  image: dtzar/helm-kubectl:3.8.2
cyril.cros's avatar
cyril.cros committed
  needs:
    - deploy_to_k8s
cyril.cros's avatar
cyril.cros committed
  before_script:
cyril.cros's avatar
cyril.cros committed
    - echo $KUBECONFIG | base64 -d > /tmp/kubeconf
    - export KUBECONFIG=/tmp/kubeconf
cyril.cros's avatar
cyril.cros committed
  script:
    - echo 'Failed job, deleting resources'
cyril.cros's avatar
cyril.cros committed
    - envsubst < deployment/jbrowse2-dep.yml > deployment/jbrowse2-dep.yaml
    - kubectl delete -k deployment
cyril.cros's avatar
cyril.cros committed
    - if: '$CI_COMMIT_REF_NAME  == "main"'
      when: on_failure
      variables:
        JBROWSE_HOSTNAME: "genomes.arendt.embl.de"
        RELEASE_LABEL: "prod"
        INGRESS_CLASS: "external-users"
    - if: '$CI_COMMIT_REF_NAME  == "dev"'
      when: on_failure
      variables:
        JBROWSE_HOSTNAME: "genomes-dev.arendt.embl.de"
        RELEASE_LABEL: "dev"
        INGRESS_CLASS: "internal-users"
cyril.cros's avatar
cyril.cros committed
    - when: on_failure