#!/bin/bash # Dealix — Final Launch Script # Closes the 2 final code gaps + pushes to GitHub + sets up monitoring # # Usage: # 1. Ensure you have 'gh' CLI installed (brew install gh / apt install gh) # 2. Run: gh auth login # 3. Run this script: bash LAUNCH_NOW.sh # # This script: # - Applies the patch (healthz + test_sentry + DAILY_EXECUTION_SCHEDULE_AR.md) # - Pushes to GitHub # - Opens PR + merges it # - Deploys to Railway (if linked) # - Outputs exact manual steps remaining set -e GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' echo -e "${BLUE}🚀 Dealix Final Launch Closure${NC}" echo "================================" echo "" # Check prerequisites echo -e "${YELLOW}[1/8] Checking prerequisites...${NC}" for cmd in git gh; do if ! command -v $cmd &> /dev/null; then echo -e "${RED}❌ Missing: $cmd${NC}" echo " Install with: brew install $cmd (macOS) or apt install $cmd (Linux)" exit 1 fi done if ! gh auth status &> /dev/null; then echo -e "${RED}❌ GitHub CLI not authenticated${NC}" echo " Run: gh auth login" exit 1 fi echo -e "${GREEN}✅ git + gh + auth ready${NC}" # Find patch file PATCH_FILE="" for p in \ "$(pwd)/dealix_final_launch.patch" \ "$HOME/Desktop/dealix_final_launch.patch" \ "$HOME/Downloads/dealix_final_launch.patch" \ "/sessions/jolly-charming-darwin/mnt/How to use Claude/dealix_final_launch.patch"; do if [ -f "$p" ]; then PATCH_FILE="$p" break fi done if [ -z "$PATCH_FILE" ]; then echo -e "${RED}❌ Patch file not found. Looking for: dealix_final_launch.patch${NC}" echo " Place it in the same directory as this script and retry." exit 1 fi echo -e "${GREEN}✅ Patch located: $PATCH_FILE${NC}" # Clone or enter repo echo "" echo -e "${YELLOW}[2/8] Setting up working directory...${NC}" WORK_DIR="${TMPDIR:-/tmp}/dealix_launch_$$" mkdir -p "$WORK_DIR" cd "$WORK_DIR" git clone https://github.com/VoXc2/dealix.git 2>&1 | tail -2 cd dealix echo -e "${GREEN}✅ Repo cloned${NC}" # Apply patch echo "" echo -e "${YELLOW}[3/8] Applying patch...${NC}" git checkout -b launch-final-closure-$(date +%s) 2>&1 | tail -1 git am "$PATCH_FILE" echo -e "${GREEN}✅ Patch applied (healthz + test_sentry + DAILY_EXECUTION_SCHEDULE_AR.md)${NC}" # Push to origin echo "" echo -e "${YELLOW}[4/8] Pushing to GitHub...${NC}" BRANCH=$(git rev-parse --abbrev-ref HEAD) git push -u origin "$BRANCH" echo -e "${GREEN}✅ Branch pushed: $BRANCH${NC}" # Create PR echo "" echo -e "${YELLOW}[5/8] Creating Pull Request...${NC}" PR_URL=$(gh pr create \ --title "feat(launch): close final 2 launch gaps (healthz + schedule)" \ --body "Closes Launch Gate 4 remaining items: - /healthz endpoint for UptimeRobot - /_test_sentry endpoint for Sentry verification - DAILY_EXECUTION_SCHEDULE_AR.md (was 404 from cron) After merge + deploy: 1. Configure UptimeRobot to monitor \`/healthz\` 2. Set up Sentry → Slack and test via \`/_test_sentry\` 3. Daily cron will find the schedule file Generated by Dealix Launch Script." \ --base main 2>&1 | grep -oE "https://github.com[^ ]+" | head -1) echo -e "${GREEN}✅ PR: $PR_URL${NC}" # Wait for CI echo "" echo -e "${YELLOW}[6/8] Waiting for CI to pass (max 3 minutes)...${NC}" PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$') for i in {1..36}; do STATE=$(gh pr view $PR_NUMBER --json statusCheckRollup --jq '.statusCheckRollup | map(.conclusion) | if length == 0 then "pending" elif all(. == "SUCCESS") then "success" elif any(. == "FAILURE") then "failure" else "pending" end' 2>&1) if [ "$STATE" = "success" ]; then echo -e "${GREEN}✅ CI passed${NC}" break elif [ "$STATE" = "failure" ]; then echo -e "${RED}❌ CI failed${NC}" gh pr view $PR_NUMBER exit 1 fi echo -n "." sleep 5 done echo "" # Merge echo "" echo -e "${YELLOW}[7/8] Merging PR...${NC}" gh pr merge $PR_NUMBER --squash --delete-branch --auto 2>&1 | tail -3 echo -e "${GREEN}✅ PR merged to main${NC}" # Output final manual steps echo "" echo -e "${BLUE}[8/8] Final Manual Steps (I cannot do these for you):${NC}" echo "" echo -e "${YELLOW}🔴 Step A — Railway${NC} (10 min)" echo " 1. Open: https://railway.com/project/54bb60b4-d059-4dd1-af57-bc44c702b9f0" echo " 2. Settings → Start Command: clear or set to /app/start.sh" echo " 3. Variables → Raw Editor → paste from dealix_railway_vars.txt" echo " 4. Wait for deploy Active → note the public URL" echo "" echo -e "${YELLOW}🔴 Step B — Moyasar${NC} (5 min)" echo " 1. Open: https://dashboard.moyasar.com/webhooks" echo " 2. Rotate secret (leak in git history)" echo " 3. Add webhook: /api/v1/webhooks/moyasar" echo " 4. Use new secret in both Moyasar + Railway env" echo "" echo -e "${YELLOW}🔴 Step C — Monitoring${NC} (30 min)" echo " 1. Sentry → Slack integration: /_test_sentry" echo " 2. UptimeRobot on: /healthz" echo " 3. PostHog test event verification" echo "" echo -e "${YELLOW}🔴 Step D — First Transaction${NC} (15 min)" echo " 1. Run: bash dealix_1_riyal_test.sh " echo " 2. Pay 1 SAR with your card" echo " 3. Verify: payment in Moyasar + webhook logged + DB record" echo "" echo -e "${YELLOW}🟡 Step E — First Outreach${NC} (20 min)" echo " 1. LinkedIn DM to Abdullah Asiri (Lucidya)" echo " 2. Log in 14day_tracker" echo " 3. Schedule followup reminders" echo "" echo -e "${GREEN}🎉 GitHub launch closure complete.${NC}" echo -e "${GREEN} Repo: https://github.com/VoXc2/dealix${NC}" echo -e "${GREEN} Next: Execute Steps A-E above. Total ~80 minutes.${NC}" echo "" # Cleanup cd / rm -rf "$WORK_DIR" echo -e "${BLUE}Working directory cleaned up.${NC}"