From c4547d2e52f8d1e88b1ed2dd2b6b012171587e7b Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Mon, 23 Mar 2026 21:20:58 -0400 Subject: [PATCH] feat: live staging with auto-refresh on main push (Fixes #33) - index.html: polls Gitea API every 30s for new commits on main; shows countdown banner and auto-reloads when SHA changes - Dockerfile + docker-compose.yml: serve the site via nginx; main on :4200, staging on :4201 - deploy.sh: rebuild and restart a named service - .gitea/workflows/deploy.yml: SSH-deploy to host on every push to main (requires DEPLOY_HOST / DEPLOY_USER / DEPLOY_SSH_KEY repo secrets) Co-Authored-By: Claude Sonnet 4.6 --- .gitea/workflows/deploy.yml | 26 +++++++++++++++++++ Dockerfile | 6 +++++ deploy.sh | 17 +++++++++++++ docker-compose.yml | 20 +++++++++++++++ index.html | 50 +++++++++++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+) create mode 100644 .gitea/workflows/deploy.yml create mode 100644 Dockerfile create mode 100755 deploy.sh create mode 100644 docker-compose.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..babe5c8 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,26 @@ +name: Deploy Nexus + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Deploy to host via SSH + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.DEPLOY_HOST }} + username: ${{ secrets.DEPLOY_USER }} + key: ${{ secrets.DEPLOY_SSH_KEY }} + script: | + cd ~/the-nexus || git clone http://143.198.27.163:3000/Timmy_Foundation/the-nexus.git ~/the-nexus + cd ~/the-nexus + git fetch origin main + git reset --hard origin/main + ./deploy.sh main diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..615001a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM nginx:alpine +COPY . /usr/share/nginx/html +RUN rm -f /usr/share/nginx/html/Dockerfile \ + /usr/share/nginx/html/docker-compose.yml \ + /usr/share/nginx/html/deploy.sh +EXPOSE 80 diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..76f1fd3 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# deploy.sh — spin up (or update) the Nexus staging environment +# Usage: ./deploy.sh — rebuild and restart nexus-main (port 4200) +# ./deploy.sh staging — rebuild and restart nexus-staging (port 4201) +set -euo pipefail + +SERVICE="${1:-nexus-main}" + +case "$SERVICE" in + staging) SERVICE="nexus-staging" ;; + main) SERVICE="nexus-main" ;; +esac + +echo "==> Deploying $SERVICE …" +docker compose build "$SERVICE" +docker compose up -d --force-recreate "$SERVICE" +echo "==> Done. Container: $SERVICE" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d4587f2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.9" + +services: + nexus-main: + build: . + container_name: nexus-main + restart: unless-stopped + ports: + - "4200:80" + labels: + - "deployment=main" + + nexus-staging: + build: . + container_name: nexus-staging + restart: unless-stopped + ports: + - "4201:80" + labels: + - "deployment=staging" diff --git a/index.html b/index.html index 3a2c6ea..2f848f3 100644 --- a/index.html +++ b/index.html @@ -118,5 +118,55 @@ + + +
⚡ NEW DEPLOYMENT DETECTED — Reloading in 5s…
+ +