Skip to content

Commit d3ba964

Browse files
fix(playground): deploy Nginx config alongside proxy (DAK-6968) (#230)
PR#229 merged burst 20→50 in nginx-playground.conf but the proxy deploy workflow only SCPs the Node.js proxy — it never touches Nginx. Add a deploy step that SCPs the conf, substitutes SSL paths from the running config, validates with nginx -t, and reloads. Also trigger on nginx-playground.conf path changes. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent aef8879 commit d3ba964

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/playground-proxy-deploy.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
paths:
1111
- 'docker/playground/proxy/**'
1212
- 'docker/docker-compose.playground.yml'
13+
- 'docker/nginx-playground.conf'
1314
- '.github/workflows/playground-proxy-deploy.yml'
1415
workflow_dispatch:
1516
inputs:
@@ -64,6 +65,48 @@ jobs:
6465
${{ env.PROXY_SRC }}/package.json \
6566
root@${{ env.PLAYGROUND_IP }}:${{ env.PROXY_DEST }}/
6667
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+
67110
- name: Rebuild and restart proxy
68111
run: |
69112
ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no "root@${{ env.PLAYGROUND_IP }}" bash << 'REMOTE'
@@ -85,7 +128,7 @@ jobs:
85128
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
86129
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
87130
run: |
88-
MSG="✅ [Platform] Playground proxy deployed — $(git log -1 --format='%s')"
131+
MSG="✅ [Platform] Playground proxy + Nginx deployed — $(git log -1 --format='%s')"
89132
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
90133
-d "chat_id=${TELEGRAM_CHAT_ID}&text=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$MSG")" > /dev/null
91134

0 commit comments

Comments
 (0)