Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Book
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUDE
Book
Commits
465470bf
Commit
465470bf
authored
3 months ago
by
Kwangjin Lee
Browse files
Options
Downloads
Patches
Plain Diff
combined build and deploy
parent
48c6b8b5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#260155
failed
3 months ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+48
-58
48 additions, 58 deletions
.gitlab-ci.yml
with
48 additions
and
58 deletions
.gitlab-ci.yml
+
48
−
58
View file @
465470bf
...
...
@@ -2,7 +2,6 @@ image: python:3.10-bullseye
stages
:
-
build
-
deploy
variables
:
PIP_CACHE_DIR
:
"
$CI_PROJECT_DIR/.cache/pip"
...
...
@@ -20,82 +19,73 @@ before_script:
-
source venv/bin/activate
-
pip install -r requirements.txt
build-
book
:
build-
and-deploy
:
stage
:
build
script
:
# Previous debug commands remain the same
# Debug info before build
-
echo "Starting build process..."
-
df -h
-
pwd
-
ls -la
# Build the book based on branch
-
|
if [ "$CI_COMMIT_BRANCH" == "release" ]; then
echo "Building production version"
DEPLOY_URL="https://mude.citg.tudelft.nl/2024/book"
DEPLOY_HOOK="book-deploy-production"
ENV_NAME="production"
teachbooks build --publish book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
else
echo "Building draft version"
DEPLOY_URL="https://mude.citg.tudelft.nl/2024/book/draft"
DEPLOY_HOOK="book-deploy-draft"
ENV_NAME="draft"
teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
fi
# Cleanup steps
-
echo "Directory sizes before cleanup:" | tee -a build_debug.log
-
du -sh book/_build/* | tee -a build_debug.log
-
echo "Cleaning up build artifacts..."
-
rm -rf book/_build/.doctrees
# - rm -rf book/_build/jupyter_execute
# - find book/_build -name "*.ipynb" -delete
# - find book/_build -name "__pycache__" -exec rm -rf {} +
# - find book/_build -name "*.pyc" -delete
# Keep debug output
-
echo "Final directory sizes after cleanup:" | tee -a build_debug.log
-
du -sh book/_build/* | tee -a build_debug.log
-
echo $CI_JOB_ID > build_job_id.txt
# Get build size and handle deployment
-
echo "Calculating build size..."
-
SIZE=$(du -sk book/_build/html | cut -f1)
-
echo "Build size is ${SIZE}KB"
-
|
if [ "$SIZE" -lt 153600 ]; then # 150MB in KB
echo "Build size OK, proceeding with normal artifact upload"
echo $CI_JOB_ID > build_job_id.txt
# Deploy using artifacts
- |
curl -X POST "https://mude.citg.tudelft.nl/hooks/${DEPLOY_HOOK}" \
-H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-d "{\"object_kind\":\"pipeline\",\"object_attributes\":{\"status\":\"success\",\"ref\":\"${CI_COMMIT_BRANCH}\"},\"build_job_id\":$CI_JOB_ID}"
else
echo "Build too large for artifacts, deploying directly"
# Here you would add direct deployment logic
# This is a placeholder - you'll need to implement the actual direct deployment
echo "Direct deployment not implemented yet"
exit 1
fi
# Debug info after build
-
echo "Directory sizes after build:"
-
du -sh book/_build/*
-
echo "Build and deploy completed"
artifacts
:
when
:
on_success
paths
:
-
book/_build/html/**
# - book/_build/html/**/*.html
# - book/_build/html/**/*.css
# - book/_build/html/**/*.js
# - book/_build/html/_images/**/*
# - book/_build/html/_static/**/*.{css,js,woff,woff2,ttf}
-
stdout.log
-
stderr.log
-
build_job_id.txt
-
build_debug.log
# exclude:
# - book/_build/html/**/*.ipynb
# - book/_build/html/**/__pycache__/
# - book/_build/html/**/*.doctree
# - book/_build/html/**/*.pickle
expire_in
:
1 week
rules
:
-
if
:
$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "release"
-
if
:
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "release"
when
:
always
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}"
environment
:
name
:
draft
url
:
https://mude.citg.tudelft.nl/2024/book/draft
rules
:
-
if
:
$CI_COMMIT_BRANCH == "main"
name
:
$ENV_NAME
url
:
$DEPLOY_URL
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"
\ No newline at end of file
-
if
:
$CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "release"
-
if
:
$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "release"
when
:
always
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment