Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.85 KiB
variables:
  GIT_STRATEGY: fetch
  GIT_SSL_NO_VERIFY: "true"
  GIT_SUBMODULE_STRATEGY: recursive
  GIT_LFS_SKIP_SMUDGE: 1

.docker-before-script: &docker_before_script  # This is an anchor
  before_script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN http://$CI_REGISTRY

.git-before-script: &git_before_script
  before_script:
    - git config --global user.name "CR (covid cron)"
    - git config --global user.email "beepbop@example.com"
    - url_host=`git remote get-url origin | sed -e "s/https:\/\/gitlab-ci-token:.*@//g"`
    - cd /tmp/
    - git clone "https://gitlab-ci-token:${CI_PUSH_TOKEN}@${url_host}"
    - cd covid-19-public-data
    - git lfs install --local
    - PATH=$PATH:~/.local/bin

stages:
  - build
  - datasets-update
  - notebooks-update
  - finalize-update

image_build:
  stage: build
  image: docker:stable
  except:
    - /^auto-update.*$/
    - schedules
  <<: *docker_before_script

  script:
    - CI_COMMIT_SHA_7=$(echo $CI_COMMIT_SHA | cut -c1-7)
    - docker build --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA_7 .
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA_7
  tags:
    - image-build

update-build:
  stage: build
  image: docker:stable
  only:
    - schedules
  <<: *docker_before_script

  script:
    - docker build --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA-update .
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA-update
  tags:
    - image-build

datasets:
  stage: datasets-update
  image:
    name: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA-update
    entrypoint: [""]

  only:
    - schedules
  <<: *git_before_script
  script:
    - export BRANCH_NAME=auto-update-datasets-${CI_COMMIT_SHORT_SHA}
    - git checkout -b $BRANCH_NAME
    - renku dataset update covid-19_jhu-csse
    - renku dataset add covid-19_jhu-csse --force --source csse_covid_19_data/csse_covid_19_daily_reports https://github.com/CSSEGISandData/COVID-19.git
    - renku dataset update covid-19-tweet-ids