Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
lib
/
jenkins
/
workspace
/
Mudeer-web-docker
/
Filename :
.gitlab-ci.yml
back
Copy
default: tags: - deployment - shell stages: - test - sync_staging - deploy_staging - sync_main - deploy_production variables: GIT_STRATEGY: clone GIT_CLEAN_FLAGS: -ffdx GIT_DEPTH: 0 # ================================ # TEST FRONTEND # ================================ test_frontend: stage: test script: - echo "🧪 Running frontend tests..." - cd /var/www/mudder.cicd/mudeer-web - npm ci || echo "⚠️ npm install failed but continuing..." - npm run lint || echo "⚠️ No lint" - npm run test || echo "⚠️ No tests configured" allow_failure: true only: - branches # ================================ # SYNC TO STAGING BRANCH # ================================ sync_to_staging: stage: sync_staging before_script: - git config user.name "GitLab CI" - git config user.email "ci@gitlab.com" - git remote set-url origin "https://${CI_GITLAB_USER}:${GIT_AUTH_TOKEN}@gs1.abasa.com/sohaib/mudeer-web.git" script: - echo "🔄 Syncing $CI_COMMIT_REF_NAME to staging branch..." - git fetch origin - git checkout -B staging origin/staging - git merge --no-ff origin/$CI_COMMIT_REF_NAME -m "Merge $CI_COMMIT_REF_NAME into staging" - git push origin staging --force - echo "✅ Code pushed to staging branch!" only: - ci-cd when: on_success # ================================ # DEPLOY TO STAGING # ================================ deploy_staging: stage: deploy_staging script: - echo "🚀 Deploying FRONTEND to STAGING..." - STAGING_DIR="/var/www/mudder.cicd/mudeer-web/staging_build" - rm -rf "$STAGING_DIR" - mkdir -p "$STAGING_DIR" - rsync -av --exclude='node_modules' --exclude='.git' --exclude='.env*' ./ "$STAGING_DIR/" - cd "$STAGING_DIR" # إنشاء ملف .env من المتغير المحفوظ في GitLab - echo "$STAGING_ENV_FILE" > .env - echo "📦 .env for STAGING created:" - cat .env # تثبيت الحزم والبناء - npm install --omit=dev - npm run build || true - npm prune --omit=dev # إعادة تشغيل السيرفر - npx pm2 delete staging-web || true - npx pm2 start npm --name "staging-web" -- start - npx pm2 save - echo "✅ Frontend Staging deployed!" only: - staging environment: name: staging url: https://staging.mudderapi.abasa.com # ================================ # SYNC TO MAIN BRANCH # ================================ sync_to_main: stage: sync_main before_script: - git config user.name "GitLab CI" - git config user.email "ci@gitlab.com" - git remote set-url origin "https://${CI_GITLAB_USER}:${GIT_AUTH_TOKEN}@gs1.abasa.com/sohaib/mudeer-web.git" script: - echo "🔄 Syncing staging to main branch..." - git fetch origin - git checkout -B main origin/main # دمج مع تجاوز التعارضات: نأخذ تغييرات staging عند conflict - git merge -X theirs origin/staging -m "Merge staging into main (auto-resolve conflicts)" - git push origin main --force - echo "✅ Code pushed to main branch!" only: - staging when: manual # ================================ # DEPLOY TO PRODUCTION # ================================ deploy_production: stage: deploy_production script: - echo "🚀 Deploying FRONTEND to PRODUCTION..." - PROD_DIR="/var/www/mudder.cicd/mudeer-web/production_build" - rm -rf "$PROD_DIR" - mkdir -p "$PROD_DIR" - rsync -av --exclude='node_modules' --exclude='.git' --exclude='.env*' ./ "$PROD_DIR/" - cd "$PROD_DIR" # إنشاء ملف .env من المتغير المحفوظ في GitLab - echo "$PRODUCTION_ENV_FILE" > .env - echo "📦 .env for PRODUCTION created:" - cat .env # تثبيت الحزم والبناء - npm install --omit=dev - npm run build - npm prune --omit=dev # إعادة تشغيل السيرفر - npx pm2 delete production-web || true - npx pm2 start npm --name "production-web" -- start - npx pm2 save - echo "✅ Frontend Production deployed!" only: - main environment: name: production url: https://prod.mudderapi.abasa.com when: manual