CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
setup-auto-deploy.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.
| 387f0fd | 1 | # ============================================================================= |
| 2 | # Gluecron auto-deploy setup — Windows / PowerShell | |
| 3 | # Run once. Wires up GitHub Actions to auto-deploy gluecron.com on every push. | |
| 4 | # ============================================================================= | |
| 5 | # | |
| 6 | # Usage (from PowerShell, anywhere): | |
| 7 | # irm https://raw.githubusercontent.com/ccantynz-alt/Gluecron.com/main/scripts/setup-auto-deploy.ps1 | iex | |
| 8 | # | |
| 9 | # Or download + run locally: | |
| 10 | # .\scripts\setup-auto-deploy.ps1 | |
| 11 | # | |
| 12 | # What it does: | |
| 13 | # 1. Verifies gh CLI is installed + authed | |
| 14 | # 2. Generates a dedicated SSH deploy key (~/.ssh/gluecron_deploy_key) | |
| 48aff3c | 15 | # 3. Uploads the public key to root@178.104.208.252 via your existing SSH access |
| 387f0fd | 16 | # 4. Sets the three GitHub secrets the workflow needs |
| 17 | # 5. Triggers a test deploy + watches the run | |
| 18 | # ============================================================================= | |
| 19 | ||
| 20 | $ErrorActionPreference = "Stop" | |
| 21 | ||
| 22 | $REPO = "ccantynz-alt/Gluecron.com" | |
| 48aff3c | 23 | $HOST_ = "178.104.208.252" |
| 387f0fd | 24 | $USER_ = "root" |
| 25 | $KEYDIR = Join-Path $HOME ".ssh" | |
| 26 | $KEY = Join-Path $KEYDIR "gluecron_deploy_key" | |
| 27 | ||
| 28 | Write-Host "==> Gluecron auto-deploy setup" -ForegroundColor Cyan | |
| 29 | Write-Host "" | |
| 30 | ||
| 31 | # ─── 1. gh CLI check ──────────────────────────────────────────────────────── | |
| 32 | Write-Host "[1/5] Checking gh CLI..." | |
| 33 | try { | |
| 34 | gh --version | Out-Null | |
| 35 | } catch { | |
| 36 | Write-Host " gh CLI not installed. Install with:" -ForegroundColor Red | |
| 37 | Write-Host " winget install --id GitHub.cli" | |
| 38 | exit 1 | |
| 39 | } | |
| 40 | $authStatus = gh auth status 2>&1 | |
| 41 | if ($LASTEXITCODE -ne 0) { | |
| 42 | Write-Host " gh not authenticated. Run:" -ForegroundColor Red | |
| 43 | Write-Host " gh auth login" | |
| 44 | exit 1 | |
| 45 | } | |
| 46 | Write-Host " ✓ gh is installed + authed" -ForegroundColor Green | |
| 47 | ||
| 48 | # ─── 2. SSH key ───────────────────────────────────────────────────────────── | |
| 49 | Write-Host "[2/5] SSH deploy key..." | |
| 50 | if (-not (Test-Path $KEYDIR)) { New-Item -ItemType Directory -Path $KEYDIR | Out-Null } | |
| 51 | if (Test-Path $KEY) { | |
| 52 | Write-Host " ✓ existing key at $KEY (reusing)" -ForegroundColor Green | |
| 53 | } else { | |
| 54 | ssh-keygen -t ed25519 -f $KEY -N '""' -C "gluecron-github-actions" 2>&1 | Out-Null | |
| 55 | Write-Host " ✓ generated new key at $KEY" -ForegroundColor Green | |
| 56 | } | |
| 57 | ||
| 48aff3c | 58 | # ─── 3. Authorize key on the Hetzner box ────────────────────────────────────── |
| 387f0fd | 59 | Write-Host "[3/5] Authorizing key on $HOST_..." |
| 60 | $pubKey = Get-Content "$KEY.pub" -Raw | |
| 61 | $pubKey = $pubKey.Trim() | |
| 62 | $cmd = "mkdir -p ~/.ssh && grep -qF '$pubKey' ~/.ssh/authorized_keys 2>/dev/null || echo '$pubKey' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys" | |
| 63 | Write-Host " Will SSH as $USER_@$HOST_ — you may be prompted for password / existing key" -ForegroundColor Yellow | |
| 64 | ssh "$USER_@$HOST_" $cmd | |
| 65 | if ($LASTEXITCODE -ne 0) { | |
| 66 | Write-Host " ✗ Failed to authorize key. Manual step:" -ForegroundColor Red | |
| 67 | Write-Host " Get-Content $KEY.pub | ssh $USER_@$HOST_ 'cat >> ~/.ssh/authorized_keys'" | |
| 68 | exit 1 | |
| 69 | } | |
| 70 | Write-Host " ✓ deploy key authorized on $HOST_" -ForegroundColor Green | |
| 71 | ||
| 72 | # ─── 4. Set GitHub secrets ────────────────────────────────────────────────── | |
| 73 | Write-Host "[4/5] Setting GitHub Actions secrets on $REPO..." | |
| 48aff3c | 74 | $HOST_ | gh secret set HETZNER_HOST --repo $REPO |
| 75 | $USER_ | gh secret set HETZNER_USER --repo $REPO | |
| 76 | Get-Content $KEY -Raw | gh secret set HETZNER_SSH_KEY --repo $REPO | |
| 77 | Write-Host " ✓ HETZNER_HOST, HETZNER_USER, HETZNER_SSH_KEY set" -ForegroundColor Green | |
| 387f0fd | 78 | |
| 79 | # ─── 5. Trigger first deploy + watch ──────────────────────────────────────── | |
| 80 | Write-Host "[5/5] Triggering test deploy..." | |
| 48aff3c | 81 | gh workflow run hetzner-deploy.yml --repo $REPO --ref main |
| 387f0fd | 82 | Start-Sleep -Seconds 3 |
| 48aff3c | 83 | $run = (gh run list --repo $REPO --workflow=hetzner-deploy.yml --limit 1 --json databaseId | ConvertFrom-Json)[0] |
| 387f0fd | 84 | Write-Host " ✓ Run #$($run.databaseId) started. Watching..." -ForegroundColor Green |
| 85 | Write-Host "" | |
| 86 | gh run watch $run.databaseId --repo $REPO --exit-status | |
| 87 | ||
| 88 | if ($LASTEXITCODE -eq 0) { | |
| 89 | Write-Host "" | |
| 90 | Write-Host "==> 🎉 Auto-deploy is live." -ForegroundColor Green | |
| 91 | Write-Host " From now on every push to main auto-deploys to gluecron.com." | |
| 92 | Write-Host " Smoke-tested + auto-rollback on failure." | |
| 93 | Write-Host "" | |
| 94 | Write-Host " Optional next step: set ANTHROPIC_API_KEY for AI failure diagnosis:" | |
| 95 | Write-Host " gh secret set ANTHROPIC_API_KEY --repo $REPO" | |
| 96 | } else { | |
| 97 | Write-Host "" | |
| 98 | Write-Host "==> Run failed — check the Actions tab:" -ForegroundColor Red | |
| 48aff3c | 99 | Write-Host " https://github.com/$REPO/actions/workflows/hetzner-deploy.yml" |
| 387f0fd | 100 | } |