From a7da50cbe925f42d1e99bcbdad87f9c1a1c865b8 Mon Sep 17 00:00:00 2001 From: Jane Alesi Date: Sat, 21 Jun 2025 19:12:05 +0200 Subject: [PATCH] Fix GitLab CI YAML syntax - remove invalid !reference usage - Fixed script references that caused YAML validation errors - Converted to proper YAML extends syntax - Simplified build process while maintaining exact functionality - Ready for production deployment --- .gitlab-ci.yml | 132 ++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 74 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 29e0b9e..e580d0a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,7 +16,7 @@ variables: PREVIEW_BASE_URL: "https://satware.ai" # ๐Ÿ”ง Build Job Template (shared between production and preview) -.build_template: &build_template +.build_template: image: python:${PYTHON_VERSION}-slim cache: key: ${CI_COMMIT_REF_SLUG} @@ -59,6 +59,13 @@ variables: mkdocs-video watchdog +# ๐ŸŒ Production Deployment (main branch -> https://satware.ai) +pages: + extends: .build_template + stage: deploy + rules: + - if: $CI_COMMIT_REF_NAME == "main-mkdocs" + - if: $CI_COMMIT_REF_NAME == "main" script: - source venv/bin/activate @@ -66,64 +73,14 @@ variables: - mkdir -p docs/assets/css - pysassc overrides/assets/css/custom.scss docs/assets/css/custom.css - # Configure site_url based on deployment type - - | - if [ "$CI_COMMIT_REF_NAME" = "main" ] || [ "$CI_COMMIT_REF_NAME" = "main-mkdocs" ]; then - echo "๐Ÿ“ Production deployment to ${PRODUCTION_URL}" - # Keep original site_url for production - echo "Site URL: $(grep '^site_url:' mkdocs.yml)" - else - echo "๐Ÿ” Preview deployment for branch: ${CI_COMMIT_REF_NAME}" - # Extract clean branch name for URL path - BRANCH_PATH=$(echo "${CI_COMMIT_REF_NAME}" | sed 's|feature/||g' | sed 's|fix/||g' | sed 's|blog/||g' | sed 's|[^a-zA-Z0-9-]|-|g' | tr '[:upper:]' '[:lower:]') - PREVIEW_URL="${PREVIEW_BASE_URL}/${BRANCH_PATH}/" - - echo "๐Ÿ“ Updating site_url to: ${PREVIEW_URL}" - # Update site_url for preview deployment - if grep -q "^site_url:" mkdocs.yml; then - sed -i "s|^site_url:.*|site_url: ${PREVIEW_URL}|" mkdocs.yml - else - echo "site_url: ${PREVIEW_URL}" >> mkdocs.yml - fi - - # Also update use_directory_urls for better preview navigation - if grep -q "^use_directory_urls:" mkdocs.yml; then - sed -i "s|^use_directory_urls:.*|use_directory_urls: true|" mkdocs.yml - fi - - echo "โœ… Updated mkdocs.yml for preview:" - grep -E "^(site_url|use_directory_urls):" mkdocs.yml - fi + # Production deployment - keep original site_url + - echo "๐Ÿ“ Production deployment to ${PRODUCTION_URL}" + - echo "Site URL:" $(grep '^site_url:' mkdocs.yml) # Build the static site - echo "๐Ÿ—๏ธ Building MkDocs site..." - mkdocs build --verbose - # Verify build output - - echo "๐Ÿ“Š Build output summary:" - - ls -la site/ - - echo "๐Ÿ“„ Sample files:" - - find site/ -name "*.html" -type f | head -5 - - artifacts: - paths: - - site/ - expire_in: 1 hour - reports: - # Generate deployment report - dotenv: deploy.env - -# ๐ŸŒ Production Deployment (main branch -> https://satware.ai) -pages: - <<: *build_template - stage: deploy - rules: - - if: $CI_COMMIT_REF_NAME == "main-mkdocs" - - if: $CI_COMMIT_REF_NAME == "main" - script: - # Run the build template script - - !reference [.build_template, script] - # Prepare for GitLab Pages (requires 'public' directory) - echo "๐Ÿ“ฆ Preparing production deployment..." - mv site public @@ -136,10 +93,10 @@ pages: # Deployment summary - echo "๐Ÿš€ Production deployment ready:" - - echo " ๐Ÿ“ URL: ${PRODUCTION_URL}" - - echo " ๐ŸŒฟ Branch: ${CI_COMMIT_REF_NAME}" - - echo " ๐Ÿ“ฆ Files: $(find public -type f | wc -l)" - - echo " ๐Ÿ’พ Size: $(du -sh public | cut -f1)" + - echo " ๐Ÿ“ URL:" ${PRODUCTION_URL} + - echo " ๐ŸŒฟ Branch:" ${CI_COMMIT_REF_NAME} + - echo " ๐Ÿ“ฆ Files:" $(find public -type f | wc -l) + - echo " ๐Ÿ’พ Size:" $(du -sh public | cut -f1) artifacts: paths: @@ -152,22 +109,48 @@ pages: # ๐Ÿ” Preview Deployment (feature branches -> https://satware.ai/feature/xyz) preview: - <<: *build_template + extends: .build_template stage: deploy rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_REF_NAME =~ /^(feature|fix|blog|test|preview)\/.*/ - if: $CI_COMMIT_REF_NAME =~ /^(develop|staging)$/ script: - # Run the build template script - - !reference [.build_template, script] + - source venv/bin/activate - # Extract clean branch name for environment + # Build custom CSS from SCSS + - mkdir -p docs/assets/css + - pysassc overrides/assets/css/custom.scss docs/assets/css/custom.css + + # Configure site_url for preview deployment + - echo "๐Ÿ” Preview deployment for branch:" ${CI_COMMIT_REF_NAME} + # Extract clean branch name for URL path - BRANCH_PATH=$(echo "${CI_COMMIT_REF_NAME}" | sed 's|feature/||g' | sed 's|fix/||g' | sed 's|blog/||g' | sed 's|[^a-zA-Z0-9-]|-|g' | tr '[:upper:]' '[:lower:]') - PREVIEW_URL="${PREVIEW_BASE_URL}/${BRANCH_PATH}/" - # For preview, we'll create a deployable artifact that can be manually deployed - # (This will require custom deployment setup to your satware.ai server) + - echo "๐Ÿ“ Updating site_url to:" ${PREVIEW_URL} + # Update site_url for preview deployment + - | + if grep -q "^site_url:" mkdocs.yml; then + sed -i "s|^site_url:.*|site_url: ${PREVIEW_URL}|" mkdocs.yml + else + echo "site_url: ${PREVIEW_URL}" >> mkdocs.yml + fi + + # Also update use_directory_urls for better preview navigation + - | + if grep -q "^use_directory_urls:" mkdocs.yml; then + sed -i "s|^use_directory_urls:.*|use_directory_urls: true|" mkdocs.yml + fi + + - echo "โœ… Updated mkdocs.yml for preview:" + - grep -E "^(site_url|use_directory_urls):" mkdocs.yml + + # Build the static site + - echo "๐Ÿ—๏ธ Building MkDocs site..." + - mkdocs build --verbose + + # For preview, create a deployable artifact - mkdir -p preview-deploy/${BRANCH_PATH} - cp -r site/* preview-deploy/${BRANCH_PATH}/ @@ -203,11 +186,11 @@ preview: # Preview summary - echo "๐Ÿ” Preview deployment ready:" - - echo " ๐Ÿ“ URL: ${PREVIEW_URL}" - - echo " ๐ŸŒฟ Branch: ${CI_COMMIT_REF_NAME}" + - echo " ๐Ÿ“ URL:" ${PREVIEW_URL} + - echo " ๐ŸŒฟ Branch:" ${CI_COMMIT_REF_NAME} - echo " ๐Ÿ“ Path: /${BRANCH_PATH}/" - - echo " ๐Ÿ“ฆ Files: $(find preview-deploy -type f | wc -l)" - - echo " ๐Ÿ’พ Size: $(du -sh preview-deploy | cut -f1)" + - echo " ๐Ÿ“ฆ Files:" $(find preview-deploy -type f | wc -l) + - echo " ๐Ÿ’พ Size:" $(du -sh preview-deploy | cut -f1) artifacts: paths: @@ -230,6 +213,7 @@ cleanup_preview: when: manual allow_failure: true script: + - BRANCH_PATH=$(echo "${CI_COMMIT_REF_NAME}" | sed 's|feature/||g' | sed 's|fix/||g' | sed 's|blog/||g' | sed 's|[^a-zA-Z0-9-]|-|g' | tr '[:upper:]' '[:lower:]') - echo "๐Ÿงน Cleanup preview environment for ${CI_COMMIT_REF_NAME}" - echo "Manual cleanup required - remove files from server path: /${BRANCH_PATH}/" # Add your cleanup commands here, e.g.: @@ -247,12 +231,12 @@ build_info: - if: $CI_COMMIT_REF_NAME =~ /.*/ script: - echo "๐Ÿ” Build Information:" - - echo " ๐Ÿ“ Repository: ${CI_PROJECT_PATH}" - - echo " ๐ŸŒฟ Branch: ${CI_COMMIT_REF_NAME}" - - echo " ๐Ÿ“ Commit: ${CI_COMMIT_SHA:0:8}" - - echo " ๐Ÿ‘ค Author: ${GITLAB_USER_NAME}" - - echo " ๐Ÿ“… Pipeline: ${CI_PIPELINE_ID}" - - echo " ๐Ÿ”— URL: ${CI_PIPELINE_URL}" + - echo " ๐Ÿ“ Repository:" ${CI_PROJECT_PATH} + - echo " ๐ŸŒฟ Branch:" ${CI_COMMIT_REF_NAME} + - echo " ๐Ÿ“ Commit:" ${CI_COMMIT_SHA:0:8} + - echo " ๐Ÿ‘ค Author:" ${GITLAB_USER_NAME} + - echo " ๐Ÿ“… Pipeline:" ${CI_PIPELINE_ID} + - echo " ๐Ÿ”— URL:" ${CI_PIPELINE_URL} - | if [ "$CI_COMMIT_REF_NAME" = "main" ] || [ "$CI_COMMIT_REF_NAME" = "main-mkdocs" ]; then echo " ๐Ÿš€ Deployment: Production (${PRODUCTION_URL})"