Skip to content
Snippets Groups Projects
Commit ff40e821 authored by Kwangjin Lee's avatar Kwangjin Lee
Browse files

combined build and deploy

parent 465470bf
No related branches found
No related tags found
No related merge requests found
Pipeline #260156 failed
...@@ -32,16 +32,12 @@ build-and-deploy: ...@@ -32,16 +32,12 @@ build-and-deploy:
- | - |
if [ "$CI_COMMIT_BRANCH" == "release" ]; then if [ "$CI_COMMIT_BRANCH" == "release" ]; then
echo "Building production version" 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) teachbooks build --publish book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
HOOK_URL="https://mude.citg.tudelft.nl/hooks/book-deploy-production"
else else
echo "Building draft version" 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) teachbooks build book/ > >(tee stdout.log) 2> >(tee stderr.log >&2)
HOOK_URL="https://mude.citg.tudelft.nl/hooks/book-deploy-draft"
fi fi
# Get build size and handle deployment # Get build size and handle deployment
...@@ -53,15 +49,13 @@ build-and-deploy: ...@@ -53,15 +49,13 @@ build-and-deploy:
echo "Build size OK, proceeding with normal artifact upload" echo "Build size OK, proceeding with normal artifact upload"
echo $CI_JOB_ID > build_job_id.txt echo $CI_JOB_ID > build_job_id.txt
# Deploy using artifacts # Deploy using artifacts
- | curl -X POST "${HOOK_URL}" \
curl -X POST "https://mude.citg.tudelft.nl/hooks/${DEPLOY_HOOK}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \ -H "X-Gitlab-Token: glpat-m4CzsDqHnXNn3Pf5Whyd" \
-d "{\"object_kind\":\"pipeline\",\"object_attributes\":{\"status\":\"success\",\"ref\":\"${CI_COMMIT_BRANCH}\"},\"build_job_id\":$CI_JOB_ID}" -d "{\"object_kind\":\"pipeline\",\"object_attributes\":{\"status\":\"success\",\"ref\":\"${CI_COMMIT_BRANCH}\"},\"build_job_id\":$CI_JOB_ID}"
else else
echo "Build too large for artifacts, deploying directly" echo "Build too large for artifacts, deploying directly"
# Here you would add direct deployment logic # 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" echo "Direct deployment not implemented yet"
exit 1 exit 1
fi fi
...@@ -82,10 +76,13 @@ build-and-deploy: ...@@ -82,10 +76,13 @@ build-and-deploy:
expire_in: 1 week expire_in: 1 week
environment: environment:
name: $ENV_NAME name: $CI_COMMIT_BRANCH
url: $DEPLOY_URL url: $CI_ENVIRONMENT_URL
rules: rules:
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "release" - if: $CI_COMMIT_BRANCH == "main"
- if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "release" variables:
when: always CI_ENVIRONMENT_URL: "https://mude.citg.tudelft.nl/2024/book/draft"
\ No newline at end of file - if: $CI_COMMIT_BRANCH == "release"
variables:
CI_ENVIRONMENT_URL: "https://mude.citg.tudelft.nl/2024/book"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment