Automatically Exporting Drupal Content to GitHub with a Custom Script
In a recent entry from his digital garden, Dries Buytaert outlines a lightweight publishing workflow that automatically exports content from his Drupal site to a GitHub repository. The process runs daily, converting published nodes into Markdown files, committing changes, and pushing updates to github.com/dbuytaert/website-content. The system also tracks deletions and delays export by two days to allow for typo fixes before posts are archived.
The workflow depends on SSH key-based deployment and a custom Drush command housed in a site-specific module. While not yet published, the module provides a drush node:export command that feeds into a shell script. This script clones the GitHub repository, removes existing files to track deletions, exports updated content, and commits only if changes are detected.
Dries provides the full script in the post, including configuration for SSH, Git user setup, and cleanup routines. To schedule the task, he uses Acquia Cloud’s infrastructure-level job scheduler, since his site runs on Kubernetes where traditional crontab access isn’t available.
While the tutorial isn’t turnkey, it offers a reusable pattern for developers seeking to version Drupal content outside the CMS. Dries notes that this entry is more of a personal reference note than a polished guide, but shares it publicly for those who might adapt the idea.


