Deploy themes and plugins directly from Git repositories to your WordPress sites.
The Git deployment system allows you to:
- Deploy themes and plugins from any Git repository
- Track deployments and versions
- Update deployments with a single command
- Support for branches and tags
- Automatic plugin/theme activation
- Integration with notification system
# Deploy from main/master branch
./scripts/git-deploy.sh theme example.com https://github.com/user/my-theme.git
# Deploy from specific branch
./scripts/git-deploy.sh theme example.com https://github.com/user/my-theme.git develop# Deploy from main/master branch
./scripts/git-deploy.sh plugin example.com https://github.com/user/my-plugin.git
# Deploy from specific branch
./scripts/git-deploy.sh plugin example.com https://github.com/user/my-plugin.git mainDeploy a theme or plugin from a Git repository:
./scripts/git-deploy.sh <type> <domain> <repo-url> [branch]Parameters:
type:themeorplugindomain: Target WordPress siterepo-url: Git repository URL (HTTPS or SSH)branch: Optional branch or tag (defaults to main/master)
Examples:
# Deploy theme from GitHub
./scripts/git-deploy.sh theme example.com https://github.com/username/my-theme.git
# Deploy plugin from GitLab with branch
./scripts/git-deploy.sh plugin example.com https://gitlab.com/username/my-plugin.git develop
# Deploy from private repo (requires SSH key)
./scripts/git-deploy.sh theme example.com git@github.com:username/private-theme.git
# Deploy specific tag
./scripts/git-deploy.sh plugin example.com https://github.com/username/my-plugin.git v1.2.3List all Git deployments for a site:
# List all deployments
./scripts/git-deploy.sh list example.com
# List only themes
./scripts/git-deploy.sh list example.com theme
# List only plugins
./scripts/git-deploy.sh list example.com pluginOutput format:
Git Deployments for example.com:
Themes:
my-theme (https://github.com/user/my-theme.git, branch: main)
another-theme (https://github.com/user/another-theme.git, branch: develop)
Plugins:
my-plugin (https://github.com/user/my-plugin.git, branch: main)
Pull latest changes for all Git-deployed themes and plugins:
./scripts/git-deploy.sh update example.comThis will:
- Find all Git-tracked deployments
- Pull latest changes from each repository
- Maintain the current branch
- Report success/failure for each update
# Navigate to the deployment
cd data/wordpress/example.com/wp-content/themes/my-theme
# Pull changes manually
git pull origin main-
Clone repository to appropriate directory:
- Themes:
wp-content/themes/<theme-name>/ - Plugins:
wp-content/plugins/<plugin-name>/
- Themes:
-
Checkout branch if specified
-
Store metadata in
.git-deployments.json:{ "themes": { "my-theme": { "repo": "https://github.com/user/my-theme.git", "branch": "main", "deployed_at": "2023-12-01T10:30:00Z" } }, "plugins": { "my-plugin": { "repo": "https://github.com/user/my-plugin.git", "branch": "develop", "deployed_at": "2023-12-01T10:35:00Z" } } } -
Activate theme or plugin via WP-CLI
-
Send notification if configured
When running update:
- Read deployment metadata
- For each deployment:
- Navigate to directory
- Run
git pull - Report status
- Send notification with summary
Use HTTPS URLs for public repositories:
./scripts/git-deploy.sh theme example.com https://github.com/user/theme.gitNo authentication required.
-
Generate SSH key in the FrankenPHP container:
docker exec -it wpfleet_frankenphp ssh-keygen -t ed25519 -C "wpfleet@example.com"
-
Add public key to your Git provider:
docker exec wpfleet_frankenphp cat /root/.ssh/id_ed25519.pub -
Deploy with SSH URL:
./scripts/git-deploy.sh theme example.com git@github.com:user/private-theme.git
- Create a PAT in your Git provider
- Use HTTPS URL with token:
./scripts/git-deploy.sh theme example.com https://TOKEN@github.com/user/private-theme.git
Note: Tokens are stored in .git-deployments.json. Ensure proper file permissions.
./scripts/git-deploy.sh theme example.com https://github.com/user/theme.git develop./scripts/git-deploy.sh theme example.com https://github.com/user/theme.git v1.2.3cd data/wordpress/example.com/wp-content/themes/my-theme
git checkout main
git pull origin main-
Deploy to staging:
./scripts/git-deploy.sh theme staging.example.com https://github.com/user/theme.git develop
-
Test on staging:
- Verify functionality
- Check for errors
- Review changes
-
Deploy to production:
./scripts/git-deploy.sh theme example.com https://github.com/user/theme.git main
Create a webhook on your Git provider:
# Webhook endpoint (example using simple HTTP server)
curl -X POST https://your-server.com/deploy \
-d "site=example.com" \
-d "type=theme" \
-d "name=my-theme"Handle the webhook to trigger updates:
#!/bin/bash
# webhook-handler.sh
SITE=$1
TYPE=$2
NAME=$3
cd /path/to/wpfleet/data/wordpress/$SITE/wp-content/${TYPE}s/$NAME
git pull origin main
# Send notification
/path/to/wpfleet/scripts/notify.sh success \
"Auto-Deploy" \
"Updated $NAME on $SITE"Sync local changes to server:
# On local machine
git push origin develop
# On server
./scripts/git-deploy.sh update example.com- main/master: Production-ready code
- develop: Development and testing
- feature/*: Feature branches
- hotfix/*: Emergency fixes
Always test on staging first:
# Deploy to staging
./scripts/git-deploy.sh theme staging.example.com https://github.com/user/theme.git develop
# Test thoroughly
# Deploy to production
./scripts/git-deploy.sh theme example.com https://github.com/user/theme.git mainUse tags for releases:
# Create tag
git tag -a v1.0.0 -m "Version 1.0.0"
git push origin v1.0.0
# Deploy tagged version
./scripts/git-deploy.sh theme example.com https://github.com/user/theme.git v1.0.0Run tests before deploying:
# In your CI/CD pipeline
npm test
composer test
./vendor/bin/phpunit
# If tests pass, trigger deployment
./scripts/git-deploy.sh theme example.com https://github.com/user/theme.git mainKeep previous versions for easy rollback:
# If new version has issues
cd data/wordpress/example.com/wp-content/themes/my-theme
git checkout v1.0.0 # Previous stable versionDocument your deployments:
# List all deployments
./scripts/git-deploy.sh list example.com > deployments.txtError: Permission denied or repository not found
Solutions:
-
Verify repository URL:
git ls-remote https://github.com/user/repo.git
-
Check SSH key for private repos:
docker exec wpfleet_frankenphp ssh -T git@github.com -
Verify access token for HTTPS with private repos
Error: Local changes would be overwritten
Solutions:
-
Stash local changes:
cd data/wordpress/example.com/wp-content/themes/my-theme git stash git pull origin main -
Reset to remote:
git fetch origin git reset --hard origin/main
Check WP-CLI:
# Check if theme installed
./scripts/wp-cli.sh example.com theme list
# Manually activate
./scripts/wp-cli.sh example.com theme activate my-theme
# Check for errors
./scripts/wp-cli.sh example.com theme status my-themeIf .git-deployments.json is missing or corrupted:
-
Recreate metadata:
# List Git repositories in themes/plugins find data/wordpress/example.com/wp-content/{themes,plugins} -name ".git" -type d
-
Manually create entries in
.git-deployments.json
-
Protect SSH keys: Set proper permissions
docker exec wpfleet_frankenphp chmod 600 /root/.ssh/id_ed25519 -
Secure tokens: Don't commit
.git-deployments.jsonwith tokens -
Review code: Always review Git-deployed code for security issues
-
Use signed commits: Verify commit authenticity
git log --show-signature
-
Limit access: Use deployment keys with read-only access when possible
name: Deploy to WPFleet
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy theme
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd /path/to/wpfleet
./scripts/git-deploy.sh update example.comdeploy:
stage: deploy
script:
- ssh user@server 'cd /path/to/wpfleet && ./scripts/git-deploy.sh update example.com'
only:
- main