Deploys
On this page
Deploy code from GitHub or any Git host, customize your bash deploy script, and edit environment files directly on the server.
Connect a repository
- GitHub (recommended): open Source control in your workspace sidebar and click Connect with GitHub to authorize your GitHub account. Once connected, Crabsmith lists your repositories when creating a site and automatically manages each site's read-only deploy key and push webhook.
- Other Git hosts: choose Custom Git URL under Source, enter the SSH clone URL and branch, and create the site. For private repositories, copy the site's deploy key from Deployment → Deploy key, grant it read access at your Git host, and click Deploy now.
- No repository: you can still run a custom deploy script manually without a Git repo.
How a deploy works
When you push to the tracked branch or click Deploy now, Crabsmith runs up to three stages as crab in the site's folder:
- Fetch: pulls and checks out the latest commit from your repository.
- Deploy script: runs your bash script with these environment variables available:
SITE_DOMAIN,SITE_BRANCH,SITE_COMMIT,PORT,PHP_FPM, and the site's PHP binary first inPATH. (The default timeout is 900 seconds; it can be adjusted from 60 to 3600 seconds via the API.) - Health check (Proxy sites only): checks that your app answers on the site's port within 30 seconds (skipped on the initial deploy when the app daemon is queued to start right after).
Environment variables
Open the site's Environment tab to view and edit the live env file on the server (.env, .env.local, or any relative filename configured for the site).
- The file on the server is the only source of truth—Crabsmith never stores a copy.
- Keep the live env file untracked in Git (
.gitignore) so deploys never overwrite it. - On the first deploy, if the env file doesn't exist yet and your repo has
.env.example, Crabsmith copies it as a starting point. - Files are written as
crabwith permissions0600. - Click Reload if you edited the file over SSH.
Webhooks and push to deploy
With GitHub connected through Source control, push-to-deploy is configured automatically.
To wire up a webhook manually:
- GitHub webhook: copy the webhook URL and secret from Settings. In GitHub, choose application/json, the push event, and paste the secret. Only signed pushes to the site's branch trigger a deploy; multiple pushes queued at once are collapsed into one deploy of the latest commit.
- Generic CI / deploy hook: send a
POSTrequest to the site's deploy hook URL with its bearer secret (Authorization: Bearer <secret>). Rotating the secret invalidates old credentials for both hooks.
Run one-off commands
Open a site's Commands tab to run one-off commands directly in the site's folder—useful for migrations, cache clearing, seeding, or running CLI tools like php artisan, php bin/console, php cua, or npm.
- Commands run as
crabinside/home/crab/<original-domain>, with the site's PHP version first inPATH. - Each command runs as a tracked operation (up to 15 minutes) and is saved in the site's command history with its output and who ran it.
For an interactive session (such as tinker, vim, or htop), use the server's Terminal.
Rolling back a bad deploy
Because deploys update files in place, there is no one-click rollback button. To revert a bad release cleanly:
- Revert in Git (recommended): run
git revert <bad-commit>(or revert the PR on GitHub) and push to your tracked branch. Crabsmith deploys the reverted code automatically and keeps your Git history clean. - Urgent rollback on the server: open the server's Terminal,
cd /home/crab/<original-domain>, inspect recent commits withgit log -n 5 --oneline, and check out a known-good commit before restarting your daemon or reloading PHP-FPM. Follow up with a Git revert so the next deploy doesn't bring the broken commit back.
When a deploy fails
- Fetch failed: make sure the deploy key has read access to the repository, you used the SSH clone URL for a private custom repo, and the branch name matches.
- Script failed: open the failed step to see its last lines of output, fix the issue, and click Deploy now again.
- Port check failed (Proxy sites): open the app daemon's Logs under Processes, verify it listens on
127.0.0.1:$PORT, and confirm your deploy script restarts it. - Stream disconnected: click Reconnect to progress—this reattaches to the running deploy without starting a second one.