image: debian:stable-slim

before_script:
  - export DEBIAN_FRONTEND=noninteractive
  - apt -qq update
  - apt-get -qq install apt-utils

  - echo "Europe/Paris" > /etc/timezone
  - dpkg-reconfigure tzdata

  - apt-get -qq install locales
  - echo "en_US.UTF-8 UTF-8" >>/etc/locale.gen
  - ln -s /etc/locale.alias /usr/share/locale/locale.alias
  - locale-gen && locale-gen en_US.UTF-8 && dpkg-reconfigure locales
  - export LANGUAGE=en_US.UTF-8
  - export LANG=en_US.UTF-8
  - export LC_ALL=en_US.UTF-8
  - export LC_CTYPE=en_US.UTF-8

  # Note: openssh-client contains ssh-agent, that it is required by Docker.
  - apt-get -qq install --no-install-recommends ca-certificates git openssh-client python3 python3-lxml python3-requests

  # Install ssh-agent if not already installed, it is required by Docker.
  - 'which ssh-agent || apt-get install openssh-client --yes'

  # Run ssh-agent (inside the build environment)
  - eval $(ssh-agent -s)

  # Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
  - ssh-add <(echo "$SSH_PRIVATE_KEY")

  # Add the SSH keys of remote Git servers, to disable host key checking questions.
  - mkdir -p ~/.ssh
  - ssh-keyscan -t rsa git.nomics.world >> ~/.ssh/known_hosts

  - git config --global user.email "eurostat-fetcher@db.nomics.world"
  - git config --global user.name "Eurostat Fetcher"
  - git config --global push.default simple

job_fetch:
  only:
    - master
  script:
    - ./eurostat_bulk_fetcher.py --push eurostat-source-data
  stage: build
  tags:
    - docker