Deploying content and data files from a submodule with Wercker

Hacks/Hackers wanted their new site to allow literally anyone to make a pull request, propose a new post, or suggest edits to an existing one. They also wanted to set up separate groups of admins with permission to approve code vs. content.

I ended up creating two public GitHub repos. The main repo contains all the Hugo config and the theme, and loads the content repo as a submodule. Because the content admins are responsible for the Hugo data files, I nested them in /content/data. This works as expected; you just need to remove the /public/data directory after running the Hugo build.

I’m using Wercker to deploy to S3. When there are new commits on the master branch of the content repo, that repo’s Wercker deploy script creates a new branch in the main repo and updates the submodule reference. Then the main repo’s deploy script merges the submodule update into the master and production branches and pushes those back to GitHub, which triggers deploys to the staging and production S3 buckets.

Bash scripting and Docker are definitely not my strong suits so I assume there are ways to make this process less convoluted. I’m open to suggestions and questions!

2 Likes