Skip to content

try9

try9 #9

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/your-app-directory
- name: Run on droplet
run: |
ssh -o StrictHostKeyChecking=no root@${{ secrets.DROPLET_IP }} << 'EOF'
set -e
cd /root/your-app-directory
# Export environment variables
export DATABASE_URL="${{ secrets.DATABASE_URL }}"
export JWT_SECRET="${{ secrets.JWT_SECRET }}"
# Install Node.js and npm if missing
if ! command -v npm &> /dev/null; then
apt-get update
apt-get install -y nodejs npm
fi
# Install pm2 if missing
if ! command -v pm2 &> /dev/null; then
npm install -g pm2
fi
# Ensure bun is available in PATH
export PATH="$HOME/.bun/bin:$PATH"
# Restart or start the application with pm2, updating env vars
pm2 restart excalidar --update-env \
|| pm2 start "bun run start" --name excalidar
pm2 save
EOF