version: 2

jobs:
  doc:
    docker:
      - image: cimg/python:3.8.12
    environment:
      - USERNAME: "glemaitre"
      - ORGANIZATION: "imbalanced-learn"
      - DOC_REPO: "imbalanced-learn.github.io"
      - DOC_URL: ""
      - EMAIL: "g.lemaitre58@gmail.com"
      - MINICONDA_PATH: ~/miniconda
      - CONDA_ENV_NAME: testenv
      - OMP_NUM_THREADS: 1
      - PYTHON_VERSION: 3
      - NUMPY_VERSION: 'latest'
      - SCIPY_VERSION: 'latest'
      - SKLEARN_VERSION: 'latest'
      - MATPLOTLIB_VERSION: 'latest'
      - SPHINX_VERSION: 'min'
      - PANDAS_VERSION: 'latest'
      - SPHINX_GALLERY_VERSION: 'latest'
      - NUMPYDOC_VERSION: 'latest'
      - SPHINXCONTRIB_BIBTEX_VERSION: 'latest'
      - PYDATA_SPHINX_THEME_VERSION: 'latest'
    steps:
      - add_ssh_keys:
          fingerprints:
            - "34:ea:b1:d9:b1:e2:5d:79:81:c4:d0:39:ca:85:e1:ef"
      - checkout
      - run: ./build_tools/circle/checkout_merge_commit.sh
      - run: ./build_tools/circle/build_doc.sh
      - store_artifacts:
          path: doc/_build/html
          destination: doc
      - store_artifacts:
          path: ~/log.txt
      - persist_to_workspace:
          root: doc/_build/html
          paths: .
      - attach_workspace:
          at: doc/_build/html
      - run: ls -ltrh doc/_build/html
      - deploy:
          command: |
            if [[ "${CIRCLE_BRANCH}" =~ ^master$|^[0-9]+\.[0-9]+\.X$ ]]; then
              bash ./build_tools/circle/push_doc.sh doc/_build/html
            fi
    filters:
      branches:
        ignore: gh-pages

workflows:
  version: 2
  build-doc-and-deploy:
    jobs:
      - doc
