ci: add Forgejo workflow and systemd service units for beta deployment
Some checks failed
Deploy Beta (NATIVE) / deploy (push) Failing after 13s
Some checks failed
Deploy Beta (NATIVE) / deploy (push) Failing after 13s
This commit is contained in:
parent
96bf906d52
commit
3157985b9f
3 changed files with 140 additions and 0 deletions
98
.forgejo/workflows/beta.yml
Normal file
98
.forgejo/workflows/beta.yml
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
name: Deploy Beta (NATIVE)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- beta
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: Package Application
|
||||
run: |
|
||||
tar -czf app.tar.gz --exclude=.git --exclude=node_modules --exclude=logs --exclude=.turbo --exclude=.output .
|
||||
|
||||
- name: Deploy to cisystem EC2
|
||||
run: |
|
||||
apk add --no-cache openssh-client
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.BETA_EC2_SSH_KEY }}" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
|
||||
# Copy app archive and systemd service files
|
||||
scp -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa app.tar.gz getcito.service getcito-worker.service ${{ secrets.BETA_EC2_USERNAME }}@${{ secrets.BETA_EC2_HOST }}:/tmp/
|
||||
|
||||
# Execute deployment commands on cisystem
|
||||
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa ${{ secrets.BETA_EC2_USERNAME }}@${{ secrets.BETA_EC2_HOST }} << 'EOF'
|
||||
set -e
|
||||
|
||||
# ── 1. Target Directory Setup ────────────────────────────────
|
||||
sudo mkdir -p /home/ubuntu/getcito/logs
|
||||
sudo chown -R ubuntu:ubuntu /home/ubuntu/getcito
|
||||
tar -xzf /tmp/app.tar.gz -C /home/ubuntu/getcito
|
||||
|
||||
cd /home/ubuntu/getcito
|
||||
|
||||
# ── 2. Environment Configuration ────────────────────────────
|
||||
if [ ! -f .env ]; then
|
||||
cat << 'ENVEOF' > .env
|
||||
NODE_ENV=production
|
||||
PORT=3003
|
||||
NITRO_PORT=3003
|
||||
NITRO_HOST=127.0.0.1
|
||||
HOST=127.0.0.1
|
||||
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=5432
|
||||
DB_USER=vignesh
|
||||
DB_PASSWORD=vignesh_secret_pass_2026
|
||||
DB_NAME=getcito
|
||||
DATABASE_URL=postgres://vignesh:vignesh_secret_pass_2026@127.0.0.1:5432/getcito
|
||||
|
||||
DEPLOYMENT_MODE=local
|
||||
VITE_DEPLOYMENT_MODE=local
|
||||
BETTER_AUTH_SECRET=9f8c6e2b1a3d5e7f0b2c4d6e8a1c3e5f
|
||||
APP_URL=https://seo.tradhox.com
|
||||
VITE_APP_URL=https://seo.tradhox.com
|
||||
VITE_APP_TIMEZONE=Asia/Kolkata
|
||||
VITE_APP_LOCALE=en-IN
|
||||
DISABLE_TELEMETRY=1
|
||||
|
||||
SCRAPE_TARGETS=chatgpt:openai-api
|
||||
ONBOARDING_LLM_TARGET=chatgpt:openai-api
|
||||
OPENAI_API_KEY=dummy_key_for_testing
|
||||
ANTHROPIC_API_KEY=dummy_key_for_testing
|
||||
DATAFORSEO_LOGIN=dummy_login
|
||||
DATAFORSEO_PASSWORD=dummy_password
|
||||
ENVEOF
|
||||
fi
|
||||
|
||||
cp .env apps/web/.env
|
||||
|
||||
# ── 3. Install Dependencies & Build ─────────────────────────
|
||||
export PATH=/opt/node24/bin:/usr/local/bin:/usr/bin:/bin
|
||||
pnpm install --no-frozen-lockfile
|
||||
pnpm build
|
||||
|
||||
# ── 4. Systemd Service Deployment ───────────────────────────
|
||||
sudo cp /tmp/getcito.service /etc/systemd/system/getcito.service
|
||||
sudo cp /tmp/getcito-worker.service /etc/systemd/system/getcito-worker.service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable getcito.service getcito-worker.service
|
||||
sudo systemctl restart getcito.service getcito-worker.service || {
|
||||
echo "Services failed to restart! Logs:"
|
||||
sudo journalctl -u getcito.service -n 50 --no-pager
|
||||
sudo journalctl -u getcito-worker.service -n 50 --no-pager
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ── 5. Reload Nginx ─────────────────────────────────────────
|
||||
sudo nginx -t && sudo systemctl reload nginx
|
||||
|
||||
rm -f /tmp/app.tar.gz /tmp/getcito.service /tmp/getcito-worker.service
|
||||
echo "GetCito deployed successfully to https://seo.tradhox.com!"
|
||||
EOF
|
||||
19
getcito-worker.service
Normal file
19
getcito-worker.service
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=GetCito Background Worker
|
||||
After=network.target postgresql.service getcito.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=ubuntu
|
||||
WorkingDirectory=/home/ubuntu/getcito/apps/worker
|
||||
Environment=PATH=/opt/node24/bin:/usr/local/bin:/usr/bin:/bin
|
||||
Environment=NODE_ENV=production
|
||||
EnvironmentFile=/home/ubuntu/getcito/.env
|
||||
ExecStart=/opt/node24/bin/node /home/ubuntu/getcito/node_modules/tsx/dist/cli.mjs /home/ubuntu/getcito/apps/worker/src/index.ts
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=append:/home/ubuntu/getcito/logs/worker.log
|
||||
StandardError=append:/home/ubuntu/getcito/logs/worker-error.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
23
getcito.service
Normal file
23
getcito.service
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
[Unit]
|
||||
Description=GetCito Web Application (seo.tradhox.com)
|
||||
After=network.target postgresql.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=ubuntu
|
||||
WorkingDirectory=/home/ubuntu/getcito/apps/web
|
||||
Environment=PATH=/opt/node24/bin:/usr/local/bin:/usr/bin:/bin
|
||||
Environment=NODE_ENV=production
|
||||
Environment=PORT=3003
|
||||
Environment=NITRO_PORT=3003
|
||||
Environment=NITRO_HOST=127.0.0.1
|
||||
Environment=HOST=127.0.0.1
|
||||
EnvironmentFile=/home/ubuntu/getcito/.env
|
||||
ExecStart=/opt/node24/bin/node /home/ubuntu/getcito/apps/web/.output/server/index.mjs
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=append:/home/ubuntu/getcito/logs/web.log
|
||||
StandardError=append:/home/ubuntu/getcito/logs/web-error.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Loading…
Reference in a new issue