|
10 | 10 | paths: |
11 | 11 | - 'docker/playground/proxy/**' |
12 | 12 | - 'docker/docker-compose.playground.yml' |
| 13 | + - 'docker/nginx-playground.conf' |
13 | 14 | - '.github/workflows/playground-proxy-deploy.yml' |
14 | 15 | workflow_dispatch: |
15 | 16 | inputs: |
|
64 | 65 | ${{ env.PROXY_SRC }}/package.json \ |
65 | 66 | root@${{ env.PLAYGROUND_IP }}:${{ env.PROXY_DEST }}/ |
66 | 67 |
|
| 68 | + - name: Deploy Nginx config (burst + rate limits) |
| 69 | + run: | |
| 70 | + scp -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no \ |
| 71 | + docker/nginx-playground.conf \ |
| 72 | + root@${{ env.PLAYGROUND_IP }}:/tmp/nginx-playground.conf.new |
| 73 | +
|
| 74 | + ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no "root@${{ env.PLAYGROUND_IP }}" bash << 'REMOTE' |
| 75 | + set -e |
| 76 | + CURRENT=/etc/nginx/sites-available/playground |
| 77 | +
|
| 78 | + # Detect current SSL cert paths from the running config |
| 79 | + CERT=$(grep -m1 'ssl_certificate ' "$CURRENT" 2>/dev/null | awk '{print $2}' | tr -d ';') |
| 80 | + KEY=$(grep -m1 'ssl_certificate_key ' "$CURRENT" 2>/dev/null | awk '{print $2}' | tr -d ';') |
| 81 | +
|
| 82 | + if [ -z "$CERT" ] || [ -z "$KEY" ]; then |
| 83 | + CERT="/etc/nginx/ssl/playground.crt" |
| 84 | + KEY="/etc/nginx/ssl/playground.key" |
| 85 | + fi |
| 86 | +
|
| 87 | + echo "SSL cert: $CERT" |
| 88 | + echo "SSL key: $KEY" |
| 89 | +
|
| 90 | + sed "s|SSL_CERT_PLACEHOLDER|${CERT}|g; s|SSL_KEY_PLACEHOLDER|${KEY}|g" \ |
| 91 | + /tmp/nginx-playground.conf.new > /tmp/nginx-playground-rendered.conf |
| 92 | +
|
| 93 | + cp "$CURRENT" "${CURRENT}.bak" |
| 94 | + cp /tmp/nginx-playground-rendered.conf "$CURRENT" |
| 95 | +
|
| 96 | + if nginx -t 2>&1; then |
| 97 | + nginx -s reload |
| 98 | + BURST=$(grep -o 'burst=[0-9]*' "$CURRENT" | head -1) |
| 99 | + echo "✅ Nginx config deployed — $BURST active" |
| 100 | + else |
| 101 | + echo "❌ Nginx config test failed — rolling back" |
| 102 | + cp "${CURRENT}.bak" "$CURRENT" |
| 103 | + nginx -s reload |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | +
|
| 107 | + rm -f /tmp/nginx-playground.conf.new /tmp/nginx-playground-rendered.conf "${CURRENT}.bak" |
| 108 | + REMOTE |
| 109 | +
|
67 | 110 | - name: Rebuild and restart proxy |
68 | 111 | run: | |
69 | 112 | ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no "root@${{ env.PLAYGROUND_IP }}" bash << 'REMOTE' |
|
85 | 128 | TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
86 | 129 | TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} |
87 | 130 | run: | |
88 | | - MSG="✅ [Platform] Playground proxy deployed — $(git log -1 --format='%s')" |
| 131 | + MSG="✅ [Platform] Playground proxy + Nginx deployed — $(git log -1 --format='%s')" |
89 | 132 | curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \ |
90 | 133 | -d "chat_id=${TELEGRAM_CHAT_ID}&text=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$MSG")" > /dev/null |
91 | 134 |
|
|
0 commit comments