Newer
Older
image: python:3.10-bullseye
stages:
- build
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
GIT_SUBMODULE_STRATEGY: recursive
cache:
paths:
- .cache/pip
- venv/
before_script:
- python -V
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install --upgrade teachbooks
- pip install -r requirements.txt
# Previous build steps...
echo "Building production version"
teachbooks build --publish book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
echo "Building draft version"
teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
# Size analysis
# Debug directory sizes
- echo "=== Size Analysis ===" | tee size_analysis.log
- cd book/_build
# Overall sizes
- echo "Overall directory sizes:" >> ../../size_analysis.log
- du -sh * >> ../../size_analysis.log
# HTML directory breakdown
- echo -e "\nHTML directory breakdown:" >> ../../size_analysis.log
- cd html
- echo "JavaScript files:" >> ../../../size_analysis.log
- du -ch $(find . -name "*.js") | tail -n1 >> ../../../size_analysis.log
- echo "CSS files:" >> ../../../size_analysis.log
- du -ch $(find . -name "*.css") | tail -n1 >> ../../../size_analysis.log
- echo "HTML files:" >> ../../../size_analysis.log
- du -ch $(find . -name "*.html") | tail -n1 >> ../../../size_analysis.log
# Find largest files
- echo -e "\nLargest files (>1MB):" >> ../../../size_analysis.log
- find . -type f -size +1M -exec ls -lh {} \; | sort -hr >> ../../../size_analysis.log
- cd ../../..
# Essential web content
- book/_build/html/**/*.{html,css,js}
- book/_build/html/_images/**
- book/_build/html/_custom_downloads/**
- book/_build/html/genindex.html
- book/_build/html/search.html
# Required for interactive features
- book/_build/jupyter_execute/**/*.html
- book/_build/html/_static/scripts/**
# Logs and build info
- build_job_id.txt
- build_debug.log
- stdout.log
- stderr.log
# Development/build files
- "**/*.js.map"
- "**/_sources/**"
- "**/__pycache__/**"
- "**/*.pyc"
- "**/*.pickle"
- book/_build/.doctrees/**
- book/_build/jupyter_cache/**
# Keep notebooks for interactive features
# - "**/*.ipynb"
# # Build artifacts
# - "**/__pycache__/**"
# - "**/*.pyc"
# - book/_build/.doctrees/**
# - book/_build/jupyter_cache/**
# - "**/*.pickle"
deploy-draft:
stage: deploy
needs: ["build-book"]
script:
- BUILD_JOB_ID=$(cat build_job_id.txt)
- |
curl -X POST https://mude.citg.tudelft.nl/hooks/book-deploy-draft \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-d "{\"object_kind\":\"pipeline\",\"object_attributes\":{\"status\":\"success\",\"ref\":\"main\"},\"build_job_id\":$BUILD_JOB_ID}"
name: draft
url: https://mude.citg.tudelft.nl/2024/book/draft
deploy-production:
stage: deploy
needs: ["build-book"]
script:
- BUILD_JOB_ID=$(cat build_job_id.txt)
- |
curl -X POST https://mude.citg.tudelft.nl/hooks/book-deploy-production \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-d "{\"object_kind\":\"pipeline\",\"object_attributes\":{\"status\":\"success\",\"ref\":\"release\"},\"build_job_id\":$BUILD_JOB_ID}"
environment:
name: production
url: https://mude.citg.tudelft.nl/2024/book
rules:
- if: $CI_COMMIT_BRANCH == "release"