Skip to content

cors

cors #23

Workflow file for this run

name: Deploy to DigitalOcean
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Set up SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- name: Install Bun
run: |
curl -fsSL https://bun.sh/install | bash
echo "$HOME/.bun/bin" >> $GITHUB_PATH
- name: Install dependencies
run: bun install
- name: Build project
run: bun run build
- name: Sync files to droplet
run: |
rsync -avz --delete --exclude='.git' -e "ssh -o StrictHostKeyChecking=no" ./ root@${{ secrets.DROPLET_IP }}:/root/excalidraw
- name: Deploy and run on droplet
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: |
ssh -o StrictHostKeyChecking=no root@${{ secrets.DROPLET_IP }} << 'EOF'
set -e
cd /root/excalidraw
# Fix ownership and permissions
chown -R root:root .
chmod -R u+rwX .
# Ensure system dependencies
apt-get update
apt-get install -y curl nodejs npm
# Install pm2 if missing
if ! command -v pm2 &> /dev/null; then
npm install -g pm2
fi
# Install bun if missing
if ! command -v bun &> /dev/null; then
curl -fsSL https://bun.sh/install | bash
ln -sf /root/.bun/bin/bun /usr/local/bin/bun
fi
# Reinstall project dependencies
bun install
# Stop any previous apps
pm2 delete all || true
# Start frontend (Next.js)
pm2 start bun --name frontend --cwd ./apps/web -- run start
# Start HTTPS backend
pm2 start bun --name https-backend --cwd ./apps/http-backend -- run start
# Start WebSocket backend
pm2 start bun --name websocket-backend --cwd ./apps/web-socket-backend -- run start
# Save PM2 state
pm2 save
EOF