Operations Experience Project
  • Operations Experience Project
  • OX: Operator Experience
    • Good OX
  • Site Runner
    • GitOps Hosting
  • Tools
    • Site Module & Site Manager
    • ash: Drush Alias Shell
    • Drush Behat Params
Powered by GitBook
On this page
  • Features
  • DDEV powered sites on the internet
  • GitHub Actions for everything
  • Cron runs
  • Pull Request & Deployments Integration
  • Environments & Deployments
  • Secrets
  • Examples
  • Continuously Deploy main branch to a live site.
  • Deploy Preview Environments
  • Delete Preview Environment
  • Run Cron
  • Server Install
Edit on GitHub

Site Runner

Simple hosting with DDEV and Git Runners.

PreviousGood OXNextGitOps Hosting

Last updated 1 year ago

GitHub workflows for private self-hosted hosting and testing environments.

Features

DDEV powered sites on the internet

GitHub Actions for everything

Cron runs

Gain transparency into your cron process by using scheduled GitHub actions.

Pull Request & Deployments Integration

Environments & Deployments

By using GitHub Workflows, integration with Commit Statuses, Deployment API, and Environments is seamless. No custom code, no API integration.

Secrets

Store all sensitive info in GitHub repository secrets. Allows users to replace values when needed, such as for custom HTTPS certificates.

Examples

Continuously Deploy main branch to a live site.

# ./github/workflows/deploy.yml
name: Deploy to live
on:
  push:
    branches:
      - main
jobs:
  build:
    name: Deploy site
    runs-on: yourserver.com
    environment:
      name: "live"
      url: "http://www.yoursite.com?${{ github.run_id }}"
    steps:
    - uses: operations-project/site-runner-ddev@main
      with:
        path: projects/yoursite.com/live
        git-reference: main
        ddev-fqdns: yoursite.com,live.yoursite.com

Deploy Preview Environments

# ./github/workflows/pull-request-environment.yml
name: Deploy to Preview
on: [pull_request]
jobs:
  build:
    name: Deploy Site
    runs-on: yourserver.com
    environment:
      name: "pr${{ github.event.number }}"
      url: "http://pr${{ github.event.number }}.ci.yoursite.com?${{ github.run_id }}"
    steps:
    - uses: operations-project/site-runner-ddev@main
      with:
        sync: yes
        ddev-project-tld: ci.yoursite.com
        ddev-project-name: pr${{ github.event.number }}

Delete Preview Environment

name: Delete Pull Request Environment

on:
  pull_request:
    types:
      - closed

env:
  DDEV_PROJECT_PATH_FULL: "/var/platform/Sites/${{ github.repository }}/pr${{ github.event.number }}"
  
jobs:
  delete:
    name: Delete Environment
    runs-on: yourserver.com

    steps:
      - name: Remove site
        working-directory: ${{ env.DDEV_PROJECT_PATH_FULL }}
        run: |
          ddev remove --remove-data --omit-snapshot

      - name: Remove code
        working-directory: ${{ env.DDEV_PROJECT_PATH_FULL }}
        run: |
          rm -rf ${{ env.DDEV_PROJECT_PATH_FULL }}

Run Cron

name: Drupal Cron
on:
  schedule:
    - cron: '45 * * * *'

jobs:
  cron:
    name: Drupal Cron
    runs-on: yourserver.com
    steps:    
      - name: Run cron
        working-directory: projects/yoursite.com/live
        run: |
          ddev drush cron -v
          ddev drush status

Server Install

The repo contains Ansible roles to prepare a server for running sites like this:

  1. Users.

    • Configures users from GitHub usernames with Sudo and SSH access.

    • Creates a platform user for cloning code, running jobs, and launching sites.

  2. DDEV.

    1. Installs and configures DDEV for "casual hosting".

  3. GitHub Runners

    1. Installs and configures GitHub runners as a service.

Once installed, your server is ready to react to git pushes, running jobs from GitHub workflow config files as the platform user.

With the right GitHub workflow config, PREs will be automatically created for Pull Requests, and environments can be created manually.

GitHub - operations-project/site-runner: GitHub Runner powered CI/CdGitHub
Ansible role for preparing a server for running sites.
Logo
GitHub - operations-project/site-runner-ddev: GitHub Action for deploying a site with DDEV.GitHub
GitHub Action for launching DDEV sites.
Logo
The ddev list command run on an Operations Site Server.
GitHub Repository Actions interface.
Deployment task running from private server in GitHub UI.
Cron runs brought to you by: GitHub Actions!
Use the GitHub interface for quickly making changes and submitting a pull request
GitHub users get real-time feedback on the deployment of their code.
Immediate and direct access to easy-to-read logs, with links to running sites.
GitHub Pull Requests with Commit Checks and Deployments API integration. "View Deployment" is a direct link to the site
GitHub's Environment interface shows every deployment to every environment.