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:
Users.
Configures users from GitHub usernames with Sudo and SSH access.
Creates a platform
user for cloning code, running jobs, and launching sites.
DDEV.
Installs and configures DDEV for "casual hosting".
GitHub Runners
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.