Update build.yml

This commit is contained in:
bip production
2025-02-23 11:13:33 +08:00
committed by GitHub
parent c61e689826
commit 41fbc31194

View File

@@ -137,55 +137,7 @@ jobs:
username: ${{ secrets.VPS_USERNAME }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
# Ensure ~/.bashrc is sourced
source ~/.bashrc
# Install PM2 if not already installed
if ! command -v pm2 &> /dev/null; then
echo "PM2 is not installed. Installing now..."
bun install --global pm2
fi
# Install dotenv-cli if not already installed
if ! command -v dotenv &> /dev/null; then
echo "dotenv-cli is not installed. Installing now..."
bun install --global dotenv-cli
fi
# Find an available port
PORT=$(curl -s -X GET https://wibu-bot.wibudev.com/api/find-port | jq -r '.[0]')
if [ -z "$PORT" ] || ! [[ "$PORT" =~ ^[0-9]+$ ]]; then
echo "Invalid or missing port from API."
exit 1
fi
# Deploy to VPS
cd /var/www/projects/${{ env.APP_NAME }}/releases/${{ env.APP_VERSION }}
# Set environment variables
dotenv set DATABASE_URL "postgresql://${{ secrets.POSTGRES_USER }}:${{ secrets.POSTGRES_PASSWORD }}@localhost:5433/${{ secrets.POSTGRES_DB }}?schema=public"
dotenv set PORT "$PORT"
dotenv set NEXT_PUBLIC_WIBU_URL "localhost:$PORT"
dotenv set WIBU_UPLOAD_DIR "/var/www/projects/${{ env.APP_NAME }}/uploads"
# Create uploads directory
mkdir -p /var/www/projects/${{ env.APP_NAME }}/uploads
# Install dependencies
bun install --production
# Apply database schema
if ! bun prisma db push; then
echo "Database migration failed."
exit 1
fi
# Seed database (optional)
bun prisma db seed || echo "tidak membutuhkan seed"
# Restart the application
pm2 reload ${{ env.APP_NAME }} || pm2 start "bun run start --port $PORT" --name "${{ env.APP_NAME }}-$PORT" --namespace "${{ env.APP_NAME }}"
cat ~/.bashrc
# Step 4: Set BUILD_STATUS based on success or failure
- name: Set BUILD_STATUS