4.8 KiB
4.8 KiB
🚀 Plesk Native Git Deployment Guide
This guide shows how to deploy your Customer Portal using Plesk's built-in Git integration - much simpler than custom scripts!
🎯 Why Plesk Native Integration?
- ✅ No complex scripts - Plesk handles everything
- ✅ Automatic deployment - Deploy on every git push
- ✅ Built-in backups - Plesk creates rollback points
- ✅ Easy management - Configure via Plesk UI
- ✅ Webhook support - GitHub triggers deployment automatically
📋 Prerequisites
- Plesk hosting account with Git support
- GitHub repository (this one!)
- Domain/subdomain configured in Plesk
🛠️ Setup Steps
1. Enable Git in Plesk
- Log into your Plesk control panel
- Navigate to Websites & Domains
- Select your domain
- Click Git (in the left sidebar)
2. Add Your Repository
- Click Add Repository
- Choose Remote Git hosting
- Enter repository details:
Repository URL: https://github.com/yourusername/new-portal-website.git Repository name: customer-portal Branch: main
3. Configure Deployment
- Deployment mode: Select Automatic deployment
- Repository path:
/var/www/vhosts/yourdomain.com/git/customer-portal - Document root:
/var/www/vhosts/yourdomain.com/httpdocs - Actions: Enable Pull updates automatically
4. Set Up Authentication (For Private Repos)
If your repository is private:
- Plesk will generate an SSH public key
- Copy this key
- Go to your GitHub repo → Settings → Deploy keys
- Click Add deploy key
- Paste the Plesk SSH key
- ✅ Check Allow write access (if needed)
- Click Add key
5. Configure GitHub Webhook
- In Plesk Git settings, copy the webhook URL
- Go to GitHub repo → Settings → Webhooks
- Click Add webhook
- Paste the Plesk webhook URL
- Set Content type:
application/json - Select Just the push event
- ✅ Check Active
- Click Add webhook
🔧 Build Configuration (Optional)
If you need to run build commands (like pnpm build), you can:
Option A: Plesk Build Commands
In Plesk Git settings, add deployment actions:
# Navigate to the project root
cd /var/www/vhosts/yourdomain.com/git/customer-portal
# Install dependencies
curl -fsSL https://get.pnpm.io/install.sh | sh -
export PATH="$HOME/.local/share/pnpm:$PATH"
pnpm install --frozen-lockfile
# Build the project
pnpm build
# Copy built files to document root
cp -r apps/portal/dist/* /var/www/vhosts/yourdomain.com/httpdocs/
cp -r apps/bff/dist/* /var/www/vhosts/yourdomain.com/httpdocs/api/
Option B: Keep Simple GitHub Action
Keep a minimal build workflow (optional):
# .github/workflows/build.yml
name: Build Assets
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Build
run: |
pnpm install
pnpm build
- name: Commit built assets
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add apps/portal/dist apps/bff/dist
git commit -m "Build assets" || exit 0
git push
🎯 Deployment Process
Once configured, deployment is automatic:
- Developer pushes to
mainbranch - GitHub webhook notifies Plesk
- Plesk pulls latest changes
- Plesk runs build commands (if configured)
- Plesk deploys to document root
- Site is live! 🚀
🔍 Monitoring & Management
Check Deployment Status
- Plesk → Git → View deployment logs
- Check webhook delivery in GitHub repo settings
Manual Deployment
- Plesk → Git → Pull Updates button
Rollback
- Plesk → Git → Repository History
- Select previous commit → Deploy
🚨 Troubleshooting
Webhook Not Working
- Check webhook URL in GitHub matches Plesk
- Verify webhook is active and recent deliveries show success
- Check Plesk Git logs for errors
Build Failures
- Check Plesk deployment logs
- Verify all dependencies are available on server
- Test build commands manually via SSH
Permission Issues
- Ensure Plesk has write access to document root
- Check file permissions after deployment
🎉 Benefits You'll Get
- Zero maintenance deployment pipeline
- Instant deployments on every push
- Built-in rollback capability
- No complex GitHub Actions to maintain
- Plesk-managed file permissions and ownership
📝 Next Steps
- Follow the setup steps above
- Test with a small change (edit README.md)
- Push to main branch
- Watch it deploy automatically! 🎯
Much simpler than custom deployment scripts, right? 😊