Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
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.

setup-auto-deploy.ps1Blame100 lines · 1 contributor
387f0fdClaude1# =============================================================================
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)
48aff3cClaude15# 3. Uploads the public key to root@178.104.208.252 via your existing SSH access
387f0fdClaude16# 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"
48aff3cClaude23$HOST_ = "178.104.208.252"
387f0fdClaude24$USER_ = "root"
25$KEYDIR = Join-Path $HOME ".ssh"
26$KEY = Join-Path $KEYDIR "gluecron_deploy_key"
27
28Write-Host "==> Gluecron auto-deploy setup" -ForegroundColor Cyan
29Write-Host ""
30
31# ─── 1. gh CLI check ────────────────────────────────────────────────────────
32Write-Host "[1/5] Checking gh CLI..."
33try {
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
41if ($LASTEXITCODE -ne 0) {
42 Write-Host " gh not authenticated. Run:" -ForegroundColor Red
43 Write-Host " gh auth login"
44 exit 1
45}
46Write-Host " ✓ gh is installed + authed" -ForegroundColor Green
47
48# ─── 2. SSH key ─────────────────────────────────────────────────────────────
49Write-Host "[2/5] SSH deploy key..."
50if (-not (Test-Path $KEYDIR)) { New-Item -ItemType Directory -Path $KEYDIR | Out-Null }
51if (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
48aff3cClaude58# ─── 3. Authorize key on the Hetzner box ──────────────────────────────────────
387f0fdClaude59Write-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"
63Write-Host " Will SSH as $USER_@$HOST_ — you may be prompted for password / existing key" -ForegroundColor Yellow
64ssh "$USER_@$HOST_" $cmd
65if ($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}
70Write-Host " ✓ deploy key authorized on $HOST_" -ForegroundColor Green
71
72# ─── 4. Set GitHub secrets ──────────────────────────────────────────────────
73Write-Host "[4/5] Setting GitHub Actions secrets on $REPO..."
48aff3cClaude74$HOST_ | gh secret set HETZNER_HOST --repo $REPO
75$USER_ | gh secret set HETZNER_USER --repo $REPO
76Get-Content $KEY -Raw | gh secret set HETZNER_SSH_KEY --repo $REPO
77Write-Host " ✓ HETZNER_HOST, HETZNER_USER, HETZNER_SSH_KEY set" -ForegroundColor Green
387f0fdClaude78
79# ─── 5. Trigger first deploy + watch ────────────────────────────────────────
80Write-Host "[5/5] Triggering test deploy..."
48aff3cClaude81gh workflow run hetzner-deploy.yml --repo $REPO --ref main
387f0fdClaude82Start-Sleep -Seconds 3
48aff3cClaude83$run = (gh run list --repo $REPO --workflow=hetzner-deploy.yml --limit 1 --json databaseId | ConvertFrom-Json)[0]
387f0fdClaude84Write-Host " ✓ Run #$($run.databaseId) started. Watching..." -ForegroundColor Green
85Write-Host ""
86gh run watch $run.databaseId --repo $REPO --exit-status
87
88if ($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
48aff3cClaude99 Write-Host " https://github.com/$REPO/actions/workflows/hetzner-deploy.yml"
387f0fdClaude100}