How this site deploys

This is the first post!

So naturally it needs to explain the build and deploy pipeline for this website. From Google Cloud Platform (GCP): Source Repositories, Builder, and Firebase. The site itself is a static site generated by Hugo.

Google Cloud Source Repositories

Are git repositories integrated into the GCP environment. You can use gcloud form the Goolge Cloud SDK (builtin to Cloud Shell) to authenticate rather than setting up SSH keys.

git config --global credential.'https://source.developers.google.com'.helper gcloud.sh

Then you can use git as normal, as well as control google specific aspects of the repositories gcloud source repos commands.

Google Cloud Builder

Uses a series of docker containers to build your project. We use two community docker containers for our steps. First to generate the site from the code repository with Hugo, and then to deploy it to Firebase static hosting. In the future I plan to develop a stage that pulls new content from Google Drive so I can maintain this site from gDocs.

Firebase

Hosts the static site. This requires granting the Cloud Builder role access to Firebase in the IAM console. Firebase also takes care of TLS and DNS once you link your custom domain, in this case from GoDaddy.

GDocs –> Cloud Repositories

The goal is to write content in Google Docs and then use an App Engine script to push this content into source control and trigger a rebuild in Cloud Builder.

You will need to link your Google App to a GCP project. Open the ‘script editor’ in a Google Doc and create a project. Go to ‘Resources’ and select ‘Cloud Platform Project’. It will ask you for an ID number for an existing GCP project. You can find your project’s id from the GCP console like this. Enter that and link the projects. The bridge is now built between your deployment project in GCP and an App Script in your Google Docs environment.

GOTCHA: If you are importing your Hugo theme as a git submodule then you will need to mirror it on Google’s cloud repository or your build may fail. See these discussions for how to. Or just hard link the theme if it won’t be updated often - I ended up wanting to customize it anyway but worked out of a fork.

GOTCHA: If you deploy with TLS / HTTPS then make sure your baseURL in your config.toml is also https otherwise your site will try to load insecure elements and come out ugly.