Skip to content
Snippets Groups Projects
.gitlab-ci.yml 4.51 KiB
image: python:3.9

variables:
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip-cache"
  WEBHOOK_URL: "https://mude.citg.tudelft.nl/hooks"
  WEBHOOK_TOKEN: "glpat-Lohnt8MN6nWzpcwyhprL"
  GIT_STRATEGY: clone

cache:
  paths:
    - .pip-cache/

.setup_env:
  before_script:
    - apt-get update && apt-get install -y curl git
    - pip install jupytext nbconvert

stages:
  - setup
  - sync
  - update_repo
  - deploy

setup:
  stage: setup
  extends: .setup_env
  script:
    - echo "Dependencies installed successfully"
  artifacts:
    paths:
      - .pip-cache/

sync_notebooks:
  stage: sync
  extends: .setup_env
  script:
    - mkdir -p synced_files
    - |
      for notebook in $(find ./src -name "*.ipynb"); do
        if [ -f "$notebook" ]; then
          echo "Processing $notebook"
          relative_path=${notebook#./src/}
          synced_dir="synced_files/$(dirname $relative_path)"
          mkdir -p "$synced_dir"
          
          # Convert to various formats
          jupytext --to notebook "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).ipynb"
          jupytext --to markdown "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).md"
          jupytext --to py:percent "$notebook" -o "${synced_dir}/$(basename ${notebook%.ipynb}).py"
          
          # Strip outputs from the notebook
          jupyter nbconvert --ClearOutputPreprocessor.enabled=True --to notebook --inplace "${synced_dir}/$(basename $notebook)"
        else
          echo "No notebooks found in src directory"
          exit 1
        fi
      done
    - ls -la synced_files/  # Debug: show contents of synced_files
  artifacts:
    paths:
      - synced_files/
    expire_in: 1 hour
    when: on_success

update_repo:
  stage: update_repo
  extends: .setup_env
  dependencies:
    - sync_notebooks
  script: