diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index 372ff688..8dbb127a 100644 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -2,52 +2,50 @@ name: CI/CD Pipeline on: push: - branches: [main] + branches: + - main jobs: - lint-typecheck: - name: Lint & Type Check - runs-on: nodecloud-runner - container: - image: node:20-bullseye - + lint: + name: Lint & Typecheck + runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout code uses: actions/checkout@v4 - with: - token: ${{ github.token }} - repository: ${{ github.repository }} - - name: Enable pnpm - run: corepack enable && corepack prepare pnpm@latest --activate + - name: Install pnpm + run: npm install -g pnpm - name: Install dependencies run: pnpm install --frozen-lockfile --ignore-scripts - - name: Lint + - name: Run lint run: pnpm lint - - name: Type check + - name: Run typecheck run: pnpm typecheck deploy: - name: Deploy to NODE Cloud - runs-on: nodecloud-runner - needs: lint-typecheck - if: success() - + name: Deploy to Server + runs-on: ubuntu-latest + needs: lint steps: - name: Deploy via SSH run: | mkdir -p ~/.ssh - echo "${{ secrets.SERVER_SSH_KEY }}" > ~/.ssh/deploy_key - chmod 600 ~/.ssh/deploy_key - ssh -i ~/.ssh/deploy_key \ - -o StrictHostKeyChecking=no \ - -o UserKnownHostsFile=/dev/null \ - ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \ - "cd /srv/nodecloud/apps/biztaghavisite && \ - git pull && \ - docker compose build --no-cache && \ - docker compose up -d --force-recreate && \ - echo '✅ Deploy done'" \ No newline at end of file + echo "${{ secrets.SERVER_SSH_KEY }}" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts 2>/dev/null + ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} ' + set -e + APP_DIR="/srv/nodecloud/apps/biztaghavisite" + cd "$APP_DIR" + echo "⬇️ Pulling latest code..." + git pull origin main + echo "🐳 Building Docker image..." + docker compose build + echo "🚀 Restarting container..." + docker compose up -d --force-recreate + docker image prune -f + echo "✅ Deploy complete!" + ' diff --git a/DEPLOY.md b/DEPLOY.md index fc9fa836..62420e59 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -41,8 +41,8 @@ git commit -m "add prisma engine binaries for linux-musl" ssh root@193.105.234.35 # Create app directory -mkdir -p /srv/nodecloud/apps/biztaghavi -cd /srv/nodecloud/apps/biztaghavi +mkdir -p /srv/nodecloud/apps/biztaghavisite +cd /srv/nodecloud/apps/biztaghavisite # Clone from Gitea git clone http://git.nodecloud.ir/nodegroup/biztaghavi.git . @@ -76,7 +76,7 @@ DB_PASSWORD= ## 3. Build & launch ```bash -cd /srv/nodecloud/apps/biztaghavi +cd /srv/nodecloud/apps/biztaghavisite # Build (first time is slow — ~5-10 min due to Liara mirror rate limiting) docker compose build --no-cache @@ -152,7 +152,7 @@ The config file lives at `nginx/biztaghavi.conf` in this repo. ```bash # Install on server -cp /srv/nodecloud/apps/biztaghavi/nginx/biztaghavi.conf /etc/nginx/sites-available/biztaghavi +cp /srv/nodecloud/apps/biztaghavisite/nginx/biztaghavi.conf /etc/nginx/sites-available/biztaghavi ln -sf /etc/nginx/sites-available/biztaghavi /etc/nginx/sites-enabled/biztaghavi nginx -t && systemctl reload nginx ``` @@ -207,7 +207,7 @@ docker cp biztaghavi-next-app-1:/app/public/uploads ./uploads-backup/ ## 8. Redeployment (after code changes) ```bash -cd /srv/nodecloud/apps/biztaghavi +cd /srv/nodecloud/apps/biztaghavisite git pull # Re-apply Iran Dockerfile is already correct — no extra steps needed @@ -251,7 +251,7 @@ npm install \ tar -czf node_modules.tar.gz node_modules/ # Upload to server -scp node_modules.tar.gz root@193.105.234.35:/srv/nodecloud/apps/biztaghavi/ +scp node_modules.tar.gz root@193.105.234.35:/srv/nodecloud/apps/biztaghavisite/ # On server — extract and build without install tar -xzf node_modules.tar.gz diff --git a/scripts/health-check.sh b/scripts/health-check.sh index d8298d24..dab72e03 100755 --- a/scripts/health-check.sh +++ b/scripts/health-check.sh @@ -3,7 +3,7 @@ # Usage: bash scripts/health-check.sh set -euo pipefail -APP_DIR="/srv/nodecloud/apps/biztaghavi" +APP_DIR="/srv/nodecloud/apps/biztaghavisite" PORT=3009 echo "=== HTTP Health Check ==="