Lately I’ve been writing a lot of documentation and reports for Matsuri Japon. I work fully remotely, and with timezone differences I cannot always make it to meetings, so it is important to be more verbose with my updates. Several years ago, I introduced GSuite into the organization and everyone got used to using Google Drive to collaborate. Meeting minutes and reports are of course also uploaded there.

On the other hand, the IT department mostly collaborates on GitHub and therefore uses Markdown. Markdown is easy to write and GitHub’s Markdown rendering is very easy to read. However converting the documents written in Markdown to PDF and uploading them to Google Drive every time is toil. Now what does a good SRE do in face of toil again? Automate it.

What I ended up going with was a combination of pandoc for Markdown to PDF conversion (it actually does Markdown to HTML to PDF…) and gdrive for interacting with Google Drive and wrapped everything into a convenience docker image that we use in our documentation repositories. The rest is pretty easy: add a CircleCI (or any CI) job definition that runs on every push to the master branch to run the docker image to sync changes to Google Drive. I have created a Service Account for gdrive to use, and populated $TARGET_FOLDER_ID with the Google Drive generated folder ID for the folder to which I want to upload to.

version: 2
jobs:
  build:
    docker:
    - image: quay.io/matsuri/md2drive:latest
    working_directory: /work
    branches:
      only:
        - master
    steps:
    - checkout
    - run: echo ${GOOGLE_CREDS} | base64 --decode > /root/.gdrive/credentials.json
    - run: md2drive ${TARGET_FOLDER_ID}

Now I never need to open Google Drive and can do all my work inside VS Code and GitHub as usual. The other nice thing about working with Markdown is that if in the future we want to change where/how we share or host our documentation it is easy to migrate to other platforms as most of them support Markdown content.