What is DeployHQ?
DeployHQ (referral link) is a cloud-based deployment automation service designed to help developers and teams deploy their web applications to various hosting environments with ease and efficiency. It allows users to automate the process of deploying code from version control systems (like Git, SVN, or Mercurial) to web servers, reducing the manual effort and potential errors associated with deployment.
Key Features of DeployHQ:
- Automated Deployments: Automatically deploy code changes whenever updates are pushed to the repository.
- Environment Management: Manage different environments (e.g., development, staging, production) with ease.
- Rollback Capability: Quickly revert to previous versions if something goes wrong during deployment.
- Custom Scripts: Run custom scripts before, during, or after deployment to automate tasks such as database migrations or cache clearing.
- Integration: Supports integration with popular version control systems like GitHub, GitLab, Bitbucket, and more.
- Notifications: Receive notifications via email, Slack, or other channels when deployments occur or if there are issues.
DeployHQ is typically used by development teams who need a reliable and efficient way to deploy their applications and manage their deployment processes across different environments.
Let's go though the DeployHQ project menu and give you an overview of the changes I make and why
Table of Contents
Servers & Groups
I use a specific syntax to name my servers so it's not hard to mistake which server you applying to what settings where.
[ENVIRONMENT] Host Name (account ID)
Be sure and fill in Deployment Options -> Environment. You can use this later on in your build settings
Config Files
I deploy an separate .env
and .htaccess
for different servers here.
Sometimes, when I have a pull request pending for a third-party plugin, I temporarily overwrite a vendor file with my changes until the pull request is merged or the official update is released.
Excluded Files
Anything you don't want deployed from your repository goes here. If you are running your build in DeployHQ then you can safely exclude node_modules
or any example .env
or .htaccess
files.
SSH Commands
You want to add your commands After Changes which are executed at the end of a deployment after files have been uploaded/removed.
The command craft up
runs pending migrations and applies pending project config changes.
%path%
is a DeployHQ variable.
cd %path%
composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader
php craft up
Build Pipeline
Be sure and update your Build Configuration. Mostly what you are concerned with here is the Node version. Make sure it matches your local environment version.
%environment%
is a DeployHQ variable.
npm install
npm run %environment%
If you happen to use Cloudflare and it's Super Bot Fight Mode feature and use Critical CSS in either Webpack or Vite then you need to add a WAF rule to allow this or allow Definitely automated in Super Bot Fight Mode settings when you deploy or it will fail.
Settings
Nothing much to change here but always choose a location nearest to your server.
On rare occasions, DeployHQ may encounter deployment issues. When that happens, try temporarily changing the Project Zone to another location to resolve the problem temporarily.
Deployment
If your build has changed in any way like a new package or Node version update then click on Show Advanced Options and untick the Use Build Cache (if available) checkbox
This is the general approach I take with every Craft CMS site I deploy using DeployHQ. I hope you find my tips helpful. Happy deploying!