Blame · Line-by-line history
migrate-to-gluecron.ps1
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| e1309d5 | 1 | # ============================================================================= |
| 2 | # Migrate gluecron to itself — Phase B | |
| 3 | # Runs from Windows / PowerShell. Mirrors the GitHub repo onto gluecron.com, | |
| 4 | # wires git remote, prints the Claude Code MCP config snippet. | |
| 5 | # ============================================================================= | |
| 6 | # | |
| 7 | # Prerequisites: | |
| 8 | # - gluecron.com responds 200 on /healthz | |
| 9 | # - ccantynz-alt account registered on gluecron.com (becomes site admin | |
| 10 | # automatically via SITE_ADMIN_USERNAME env var) | |
| 11 | # - You have a Personal Access Token at /settings/tokens on gluecron.com | |
| 12 | # | |
| 13 | # Run: .\scripts\migrate-to-gluecron.ps1 | |
| 14 | # ============================================================================= | |
| 15 | ||
| 16 | $ErrorActionPreference = "Stop" | |
| 17 | ||
| 18 | $GLUECRON = "https://gluecron.com" | |
| 19 | $GH_OWNER = "ccantynz-alt" | |
| 20 | $GH_REPO = "Gluecron.com" | |
| 21 | $GLUECRON_OWNER = "ccantynz-alt" | |
| 22 | ||
| 23 | Write-Host "==> Phase B: Migrate gluecron to itself" -ForegroundColor Cyan | |
| 24 | Write-Host "" | |
| 25 | ||
| 26 | # ─── 1. Verify gluecron.com is live ───────────────────────────────────────── | |
| 27 | Write-Host "[1/5] Verifying gluecron.com is live..." | |
| 28 | try { | |
| 29 | $health = Invoke-RestMethod -Uri "$GLUECRON/healthz" -TimeoutSec 10 | |
| 30 | Write-Host " ✓ gluecron.com /healthz responded" -ForegroundColor Green | |
| 31 | } catch { | |
| 32 | Write-Host " ✗ gluecron.com is not responding. Fix Phase A first." -ForegroundColor Red | |
| 33 | exit 1 | |
| 34 | } | |
| 35 | ||
| 36 | # ─── 2. PAT prompt ────────────────────────────────────────────────────────── | |
| 37 | Write-Host "[2/5] Personal Access Token..." | |
| 38 | Write-Host " Open in browser: $GLUECRON/settings/tokens" -ForegroundColor Yellow | |
| 39 | Write-Host " Generate a token with full scope, copy it, paste below." -ForegroundColor Yellow | |
| 40 | $secureToken = Read-Host " PAT" -AsSecureString | |
| 41 | $ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureToken) | |
| 42 | $PAT = [Runtime.InteropServices.Marshal]::PtrToStringAuto($ptr) | |
| 43 | [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr) | Out-Null | |
| 44 | if (-not $PAT -or $PAT.Length -lt 10) { | |
| 45 | Write-Host " ✗ Empty / suspicious PAT, aborting." -ForegroundColor Red | |
| 46 | exit 1 | |
| 47 | } | |
| 48 | ||
| 49 | # Verify PAT works | |
| 50 | try { | |
| 51 | $me = Invoke-RestMethod -Uri "$GLUECRON/api/v2/me" -Headers @{ Authorization = "Bearer $PAT" } -TimeoutSec 10 | |
| 52 | Write-Host " ✓ Authenticated as: $($me.username)" -ForegroundColor Green | |
| 53 | } catch { | |
| 54 | Write-Host " ✗ PAT failed auth. Verify the token at $GLUECRON/settings/tokens." -ForegroundColor Red | |
| 55 | exit 1 | |
| 56 | } | |
| 57 | ||
| 58 | # ─── 3. Trigger import from GitHub ────────────────────────────────────────── | |
| 59 | Write-Host "[3/5] Importing $GH_OWNER/$GH_REPO from GitHub..." | |
| 60 | $importBody = @{ | |
| 61 | source = "github" | |
| 62 | owner = $GH_OWNER | |
| 63 | repo = $GH_REPO | |
| 64 | } | ConvertTo-Json | |
| 65 | try { | |
| 66 | $imported = Invoke-RestMethod -Method POST -Uri "$GLUECRON/import/github/repo" ` | |
| 67 | -Headers @{ Authorization = "Bearer $PAT" } ` | |
| 68 | -ContentType "application/json" ` | |
| 69 | -Body $importBody -TimeoutSec 120 | |
| 70 | Write-Host " ✓ Repo mirrored to $GLUECRON/$GLUECRON_OWNER/$GH_REPO" -ForegroundColor Green | |
| 71 | } catch { | |
| 72 | $resp = $_.Exception.Response | |
| 73 | if ($resp -and $resp.StatusCode -eq 409) { | |
| 74 | Write-Host " ✓ Already imported (409 conflict is fine)" -ForegroundColor Yellow | |
| 75 | } else { | |
| 76 | Write-Host " ✗ Import failed: $_" -ForegroundColor Red | |
| 77 | Write-Host " You can also import manually at $GLUECRON/import" | |
| 78 | exit 1 | |
| 79 | } | |
| 80 | } | |
| 81 | ||
| 82 | # ─── 4. Output git remote command ─────────────────────────────────────────── | |
| 83 | Write-Host "[4/5] Git remote setup..." | |
| 84 | $remoteUrl = "$GLUECRON/$GLUECRON_OWNER/$GH_REPO.git" | |
| 85 | Write-Host " In a clone of the repo, run:" -ForegroundColor Yellow | |
| 86 | Write-Host " git remote add gluecron $remoteUrl" | |
| 87 | Write-Host " git push -u gluecron main" | |
| 88 | Write-Host "" | |
| 89 | ||
| 90 | # ─── 5. Output MCP config ─────────────────────────────────────────────────── | |
| 91 | Write-Host "[5/5] Claude Code / Cursor MCP config..." | |
| 92 | Write-Host " Add this to your Claude Desktop config (claude_desktop_config.json):" -ForegroundColor Yellow | |
| 93 | Write-Host "" | |
| 94 | $mcpConfig = @" | |
| 95 | { | |
| 96 | "mcpServers": { | |
| 97 | "gluecron": { | |
| 98 | "command": "npx", | |
| 99 | "args": ["-y", "mcp-remote", "$GLUECRON/mcp"], | |
| 100 | "env": { | |
| 101 | "GLUECRON_TOKEN": "$PAT" | |
| 102 | } | |
| 103 | } | |
| 104 | } | |
| 105 | } | |
| 106 | "@ | |
| 107 | Write-Host $mcpConfig -ForegroundColor White | |
| 108 | ||
| 109 | Write-Host "" | |
| 110 | Write-Host "==> Phase B foundation complete." -ForegroundColor Green | |
| 111 | Write-Host " Repo mirrored. From now on you can git push to either remote." | |
| 112 | Write-Host " Phase C (cut the GitHub cord) is unlocked when:" | |
| 113 | Write-Host " - You've pushed to gluecron with no errors for ~1 week" | |
| 114 | Write-Host " - You've moved active issues/PRs over" | |
| 115 | Write-Host " - The .gluecron/workflows/deploy.yml runs cleanly on push" |