$ErrorActionPreference = "Stop"
$GLUECRON = "https://gluecron.com"
$GH_OWNER = "ccantynz-alt"
$GH_REPO = "Gluecron.com"
$GLUECRON_OWNER = "ccantynz-alt"
Write-Host "==> Phase B: Migrate gluecron to itself" -ForegroundColor Cyan
Write-Host ""
Write-Host "[1/5] Verifying gluecron.com is live..."
try {
$health = Invoke-RestMethod -Uri "$GLUECRON/healthz" -TimeoutSec 10
Write-Host " ✓ gluecron.com /healthz responded" -ForegroundColor Green
} catch {
Write-Host " ✗ gluecron.com is not responding. Fix Phase A first." -ForegroundColor Red
exit 1
}
Write-Host "[2/5] Personal Access Token..."
Write-Host " Open in browser: $GLUECRON/settings/tokens" -ForegroundColor Yellow
Write-Host " Generate a token with full scope, copy it, paste below." -ForegroundColor Yellow
$secureToken = Read-Host " PAT" -AsSecureString
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secureToken)
$PAT = [Runtime.InteropServices.Marshal]::PtrToStringAuto($ptr)
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr) | Out-Null
if (-not $PAT -or $PAT.Length -lt 10) {
Write-Host " ✗ Empty / suspicious PAT, aborting." -ForegroundColor Red
exit 1
}
try {
$me = Invoke-RestMethod -Uri "$GLUECRON/api/v2/me" -Headers @{ Authorization = "Bearer $PAT" } -TimeoutSec 10
Write-Host " ✓ Authenticated as: $($me.username)" -ForegroundColor Green
} catch {
Write-Host " ✗ PAT failed auth. Verify the token at $GLUECRON/settings/tokens." -ForegroundColor Red
exit 1
}
Write-Host "[3/5] Importing $GH_OWNER/$GH_REPO from GitHub..."
$importForm = "repo_url=$([uri]::EscapeDataString("https://github.com/$GH_OWNER/$GH_REPO"))"
try {
$r = Invoke-WebRequest -Method POST -Uri "$GLUECRON/import/github/repo" `
-Headers @{ Authorization = "Bearer $PAT" } `
-ContentType "application/x-www-form-urlencoded" `
-Body $importForm `
-MaximumRedirection 0 `
-ErrorAction SilentlyContinue
$loc = $r.Headers.Location
if ($loc -match "success") {
Write-Host " ✓ Repo mirrored to $GLUECRON/$GLUECRON_OWNER/$GH_REPO" -ForegroundColor Green
} elseif ($loc -match "error=([^&]+)") {
$err = [uri]::UnescapeDataString($matches[1])
if ($err -match "already") {
Write-Host " ✓ Already imported (existing mirror)" -ForegroundColor Yellow
} else {
Write-Host " ✗ Import error: $err" -ForegroundColor Red
Write-Host " Manual import: $GLUECRON/import" -ForegroundColor Yellow
exit 1
}
} else {
Write-Host " ? Unexpected response (location: $loc)" -ForegroundColor Yellow
}
} catch {
if ($_.Exception.Response -and $_.Exception.Response.StatusCode.value__ -eq 302) {
$loc = $_.Exception.Response.Headers.Location.OriginalString
if ($loc -match "success") {
Write-Host " ✓ Repo mirrored to $GLUECRON/$GLUECRON_OWNER/$GH_REPO" -ForegroundColor Green
} elseif ($loc -match "already") {
Write-Host " ✓ Already imported (existing mirror)" -ForegroundColor Yellow
} else {
Write-Host " ✗ Import response: $loc" -ForegroundColor Red
Write-Host " Manual import: $GLUECRON/import" -ForegroundColor Yellow
}
} else {
Write-Host " ✗ Import call failed: $_" -ForegroundColor Red
Write-Host " Manual import: $GLUECRON/import" -ForegroundColor Yellow
exit 1
}
}
Write-Host "[4/5] Git remote setup..."
$remoteUrl = "$GLUECRON/$GLUECRON_OWNER/$GH_REPO.git"
Write-Host " In a clone of the repo, run:" -ForegroundColor Yellow
Write-Host " git remote add gluecron $remoteUrl"
Write-Host " git push -u gluecron main"
Write-Host ""
Write-Host "[5/5] Claude Code / Cursor MCP config..."
Write-Host " Add this to your Claude Desktop config (claude_desktop_config.json):" -ForegroundColor Yellow
Write-Host ""
$mcpConfig = @"
{
"mcpServers": {
"gluecron": {
"command": "npx",
"args": ["-y", "mcp-remote", "$GLUECRON/mcp"],
"env": {
"GLUECRON_TOKEN": "$PAT"
}
}
}
}
"@
Write-Host $mcpConfig -ForegroundColor White
Write-Host ""
Write-Host "==> Phase B foundation complete." -ForegroundColor Green
Write-Host " Repo mirrored. From now on you can git push to either remote."
Write-Host " Phase C (cut the GitHub cord) is unlocked when:"
Write-Host " - You've pushed to gluecron with no errors for ~1 week"
Write-Host " - You've moved active issues/PRs over"
Write-Host " - The .gluecron/workflows/deploy.yml runs cleanly on push"
|