diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..cda06b1 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,20 @@ +name: Auto Deploy + +on: + push: + branches: [master] + +jobs: + check: + name: ✅ Pre-Deploy Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: TypeScript Check Backend + working-directory: backend + run: npm ci && npx tsc --noEmit + + - name: Build Frontend + working-directory: frontend + run: npm ci && npm run build diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..6cd163c --- /dev/null +++ b/deploy.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# Auto-deploy: pull latest + rebuild containers +set -e +cd "$(dirname "$0")" +echo "🔄 Pulling latest..." +git pull +echo "🐳 Rebuilding containers..." +docker compose up -d --build backend frontend +echo "🚀 Deploy complete! $(date)" diff --git a/webhook-server.js b/webhook-server.js new file mode 100644 index 0000000..e27ba86 --- /dev/null +++ b/webhook-server.js @@ -0,0 +1,32 @@ +const http = require('http') +const { execSync } = require('child_process') +const SECRET = 'luna-deploy-2026' + +const server = http.createServer((req, res) => { + if (req.method === 'POST' && req.url === '/deploy') { + let body = '' + req.on('data', chunk => body += chunk) + req.on('end', () => { + console.log(`[${new Date().toISOString()}] Deploy triggered`) + try { + const out = execSync('/home/clawd/.openclaw/workspace/luna-recipes/deploy.sh', { + cwd: '/home/clawd/.openclaw/workspace/luna-recipes', + timeout: 120000, + encoding: 'utf8' + }) + console.log(out) + res.writeHead(200) + res.end('✅ Deployed\n') + } catch (e) { + console.error('Deploy failed:', e.message) + res.writeHead(500) + res.end('❌ Deploy failed\n') + } + }) + } else { + res.writeHead(404) + res.end() + } +}) + +server.listen(9876, () => console.log('🚀 Deploy webhook listening on :9876'))