diff --git a/docs/COMPLETE_SETUP.md b/docs/COMPLETE_SETUP.md index bb5ab4d..490574f 100644 --- a/docs/COMPLETE_SETUP.md +++ b/docs/COMPLETE_SETUP.md @@ -176,6 +176,36 @@ cp -r blueprint/setup/ ./setup/ rm -rf blueprint ``` +#### Step 1.5: Configure Git Remote + +**CRITICAL**: The blueprint is a template. You must use it in YOUR own repository. + +**If you cloned the template directly**: +```bash +# Check current remote +git remote get-url origin +# If it shows: https://github.com/alirezarezvani/claude-code-github-workflow.git +# You need to update it! + +# Option A: Create new GitHub repository and update remote +gh repo create my-project --public --source=. --remote=origin + +# Option B: Manually update to existing repository +git remote set-url origin https://github.com/YOUR_USERNAME/YOUR_REPO.git + +# Verify the change +git remote get-url origin +# Should show YOUR repository, not the template +``` + +**Why this matters**: +- ❌ **Wrong**: Pushing to template repository (you don't have permission) +- ✅ **Right**: Pushing to your own repository +- The setup wizard will detect and help fix this automatically + +**If you copied files to existing repository**: +- No action needed - your git remote is already correct ✅ + #### Step 2: Configure for Your Project Type **For Web Projects**: diff --git a/docs/QUICK_START.md b/docs/QUICK_START.md index 33c3241..bc832d4 100644 --- a/docs/QUICK_START.md +++ b/docs/QUICK_START.md @@ -40,7 +40,7 @@ Before you begin, ensure you have: ### Step 1: Clone and Setup -Copy this blueprint into your project: +**Important**: This blueprint is a template. You need to use it in YOUR own repository. ```bash # Option A: Add to existing repository @@ -51,11 +51,19 @@ cp -r .blueprint-temp/.claude/ . cp -r .blueprint-temp/setup/ . rm -rf .blueprint-temp -# Option B: Start new project with blueprint +# Option B: Clone template, then create your own repository git clone https://github.com/alirezarezvani/claude-code-github-workflow.git my-project cd my-project + +# Create your own GitHub repository +gh repo create my-project --public --source=. --remote=origin + +# Or manually update git remote +git remote set-url origin https://github.com/YOUR_USERNAME/YOUR_REPO.git ``` +**Note**: The setup wizard (see below) will detect if you're still pointing to the template repository and help you update it automatically. + ### Step 2: Configure Secrets Add required secrets to your repository: diff --git a/setup/validate.sh b/setup/validate.sh index 8d8e857..8dcfe47 100644 --- a/setup/validate.sh +++ b/setup/validate.sh @@ -101,6 +101,54 @@ This script validates your repository configuration. EOF } +# ───────────────────────────────────────────────────────────────── +# 0. Git Remote Validation +# ───────────────────────────────────────────────────────────────── + +validate_git_remote() { + log_section "0. Checking Git Remote Configuration" + + # Check if in git repository + if ! git rev-parse --git-dir &> /dev/null; then + log_fail "Not in a git repository" + return 1 + fi + + # Get current remote URL + local current_remote=$(git remote get-url origin 2>/dev/null || echo "") + + if [[ -z "$current_remote" ]]; then + log_fail "No git remote 'origin' configured" + log_info "Configure with: git remote add origin " + return 1 + fi + + # Check if pointing to template repository + local template_repo="alirezarezvani/claude-code-github-workflow" + + if [[ "$current_remote" == *"$template_repo"* ]]; then + log_fail "Git remote is still pointing to template repository!" + echo "" + echo -e "${RED}⚠️ CRITICAL: You are using the blueprint template repository directly!${NC}" + echo "" + echo " Current remote: $current_remote" + echo "" + echo " This will cause issues:" + echo " • Cannot push changes (permission denied)" + echo " • Secrets set on wrong repository" + echo " • Workflows run on template, not your project" + echo "" + echo " To fix, update git remote to YOUR repository:" + echo " git remote set-url origin https://github.com//.git" + echo "" + echo " Or run the setup wizard again: ./setup/wizard.sh" + echo "" + else + log_pass "Git remote configured correctly" + log_info "Remote: $current_remote" + fi +} + # ───────────────────────────────────────────────────────────────── # 1. Branch Validation # ───────────────────────────────────────────────────────────────── @@ -618,6 +666,7 @@ main() { show_header # Run all validation checks + validate_git_remote validate_branches validate_secrets validate_workflows diff --git a/setup/wizard.sh b/setup/wizard.sh index 583588c..621008e 100755 --- a/setup/wizard.sh +++ b/setup/wizard.sh @@ -190,6 +190,100 @@ check_prerequisites() { return 0 } +# ───────────────────────────────────────────────────────────────── +# Step 1.5: Repository Remote Setup +# ───────────────────────────────────────────────────────────────── + +update_git_remote() { + log_step "Step 1.5: Repository Remote Setup" + + # Get current remote URL + local current_remote=$(git remote get-url origin 2>/dev/null || echo "") + + if [[ -z "$current_remote" ]]; then + log_error "No git remote 'origin' found" + log_info "This should not happen if prerequisites passed" + return 1 + fi + + log_info "Current remote: $current_remote" + + # Check if pointing to template repository + local template_repo="alirezarezvani/claude-code-github-workflow" + + if [[ "$current_remote" == *"$template_repo"* ]]; then + log_warning "Git remote is still pointing to the template repository!" + echo "" + echo "⚠️ You need to update the remote URL to YOUR repository." + echo "" + echo "This blueprint is a template - you should be using it in YOUR" + echo "own repository, not the original template repository." + echo "" + + # Prompt for user's repository + echo "📋 Please provide your GitHub repository information:" + echo "" + + local user_owner="" + local user_repo="" + + while [[ -z "$user_owner" ]]; do + read -p "$(echo -e "${YELLOW}?${NC} Repository owner (your username or org): ")" user_owner + if [[ -z "$user_owner" ]]; then + log_error "Repository owner cannot be empty" + fi + done + + while [[ -z "$user_repo" ]]; do + read -p "$(echo -e "${YELLOW}?${NC} Repository name: ")" user_repo + if [[ -z "$user_repo" ]]; then + log_error "Repository name cannot be empty" + fi + done + + # Construct new remote URL (using HTTPS) + local new_remote="https://github.com/$user_owner/$user_repo.git" + + echo "" + log_info "New remote URL: $new_remote" + echo "" + + if ! confirm "Update git remote to this URL?"; then + log_warning "Git remote not updated." + echo "" + log_error "You MUST update the git remote before proceeding!" + echo "" + echo "To update manually, run:" + echo " git remote set-url origin https://github.com//.git" + echo "" + echo "Then run this wizard again." + return 1 + fi + + # Update remote URL + if git remote set-url origin "$new_remote"; then + log "Git remote updated successfully!" + + # Verify the change + local updated_remote=$(git remote get-url origin) + log_info "Verified remote: $updated_remote" + + # Update global variables + REPO_OWNER="$user_owner" + REPO_NAME="$user_repo" + else + log_error "Failed to update git remote" + return 1 + fi + else + log "Git remote is already configured correctly" + log_info "Remote: $current_remote" + fi + + echo "" + return 0 +} + # ───────────────────────────────────────────────────────────────── # Step 2: Detect Project Type # ───────────────────────────────────────────────────────────────── @@ -966,6 +1060,9 @@ main() { # Step 1: Check prerequisites check_prerequisites || exit 1 + # Step 1.5: Update git remote if needed + update_git_remote || exit 1 + # Step 2: Detect project type detect_project_type