Comment via Github Pull Request

Published: 1/6/2022

Subscribe Premium $10/month

Checkout with Stripe

Editor's note: It turns out this was a horrible idea. The system is still live on this post but other sites have a more sane and typical commenting system.

In this blog post I describe the technical details and motivations of my new commenting system. If you just want to know how to comment I wrote a short explainer here. Unfortunately the whole process takes a few more clicks than I'd hoped. Basically you just have to log in to github and keep clicking the green buttons. If you hate reading just jump to the bottom and start commenting!

Why?

That's a good question. It all started when I made a pull request on a friends personal site and I thought "What fun! All online engagement should be like this". I considered about putting some text on the bottom which said "Have some comments? Submit a pull request" but who would ever be the first? They'd have to think about the design and deployment and a bunch of stuff I couldn't reasonably expect a reader to care enough to do. So I made it a little easier.

What?

I made a form you can fill out at the bottom of the page that looks like a normal comment box but when you fill it out it takes you to a github pull request. Scroll down and try it out! It turns out github has a nice url api. If you go to github.com/username/repo/new/master it'll take you to a page which prompts you to commit a new file in repo on the master branch. And if you pass in url parameters you can have the files name, text and commit message pre-filled.

I made a github action which looks at every PR that's opened and if it looks safe, automatically merges it to master. I check:

  1. The PR is one commit
  2. With one file
  3. In the comments directory
  4. Which is valid JSON
  5. With the right fields
  6. And there's no html in the fields I display

After being merged to master there is another script which rebuilds the website, syncs it to S3 and cache invalidates any blogs which have new comments.

I streamed a lot of the process and you can watch VODs here. In hindsight streaming codeforces and leetcode type stuff works a lot better though since it's low context and faster moving and you don't have to worry about secrets onscreen. I'd rather stream myself making 'useful' stuff but I'm also sort of a scrub.

You may ask: What if I want to have weird html or images or styling in my comment? Or: what if I want to publish for this site, I have my own blogs I want to put out there. You're free to edit the JSON file and add other files to your PR if you want. I'll look over new PRs and if they look safe and fun I'll merge them too. If you're a frequent commenter who I trust I might be down to give you write access to the repo as well. Just ask.

I'm releasing it with a few features unimplemented. Here's what's on my roadmap:

Let me know what you think in the comments below!




First

Paul