Header

Deploying to Grav CMS with DeployHQ

Table of Contents

What is Continuous Deployment?

Continuous Deployment (CD) is an automated software release process where code changes are automatically deployed to production after passing automated testing. DeployHQ facilitates this process by providing a robust platform for automated deployments.

Why Use DeployHQ with Grav?

  • Simple Setup: DeployHQ offers straightforward integration with various version control systems
  • Automated Deployments: Automatically deploy changes when you push to your repository
  • Built-in Build Tools: Compile assets and run commands during deployment
  • Multiple Server Support: Deploy to multiple servers with different configurations
  • Rollback Capability: Easily revert to previous deployments if issues arise

Prerequisites

  1. A Grav website
  2. Git repository (GitHub, Bitbucket, or GitLab)
  3. SSH access to your server
  4. DeployHQ account

Setting Up DeployHQ

1. Create an Account

1. Visit deployhq.com
2. Sign up for a new account
3. Verify your email address

2. Connect Your Repository

1. Go to "New Project" in DeployHQ
2. Select your repository provider (GitHub, Bitbucket, or GitLab)
3. Authorize DeployHQ to access your repositories
4. Select your Grav website repository

3. Configure Server Details

1. Navigate to "Servers" in your project
2. Click "New Server"
3. Enter your server details:
   - Server name
   - Protocol (SFTP/SSH)
   - Hostname
   - Port
   - Username
   - Authentication method (Password or SSH Key)
4. Set deployment path

Configuring Your Project

1. Branch Configuration

# Example branch configuration
Production:
  branch: main
  auto_deploy: true

Staging:
  branch: develop
  auto_deploy: true

2. Build Commands

# Example build configuration for Grav
npm install
npm run build
composer install --no-dev

3. Deployment Config File

Create a deploybuild.yml in your repository:

# deploybuild.yml
build_languages:
  - name: "node"
    version: "18"
  - name: "php"
    version: "8.0"

build_commands:
  - description: "Install NPM Dependencies"
    command: "npm install \n npm run build"
    halt_on_error: true
  - description: "Install Composer Dependencies"
    command: "composer install --no-dev"
    halt_on_error: true

build_cache_files:
  - path: node_modules/**

Deployment Configuration

1. Setting Up Automatic Deployments

1. Go to Project Settings > Automatic Deployments
2. Enable "Automatic Deployments"
3. Select branches to trigger deployments

2. Configure Deploy Hook

# Example Deploy Hook URL
https://[account].deployhq.com/deploy/[project]/[token]

3. Required Config Files

1. Navigate to Project Settings > Config Files
2. Add a file that contains:
   - GRAV_ENV=production
   - API_KEY=your_api_key

Advanced Features

1. Custom Deploy Scripts

#!/bin/bash
# deploy-script.sh
php bin/grav clear-cache
php bin/gpm update

2. Health Checks

# Health check configuration
health_check:
  url: https://yoursite.com/health
  expected_status: 200
  timeout: 30

3. Notifications

1. Configure Slack notifications
2. Set up email alerts
3. Enable webhook notifications

Best Practices

1. Security

- Use SSH keys instead of passwords
- Implement IP whitelisting
- Regular security audits

2. Deployment Strategy

1. Use staging environments
2. Implement health checks
3. Configure automatic rollbacks
4. Set up notification alerts

3. Maintenance

- Regular backup verification
- Log monitoring
- Performance tracking

This guide provides a foundation for setting up Continuous Deployment for your Grav website using DeployHQ. Adjust the configurations based on your specific needs and requirements.


Want to learn more about deployments or Wordpress? Check out our documentation or contact our support team for assistance.

Tree

Proudly powered by Katapult. Running on 100% renewable energy.