Pull Request... to DNS
A short story about an experiment I made a few years ago
A few years ago I was excited to learn Rust.
I have to admit, I haven’t really stuck with it. I went through their entire guide on learning the language and still think it’s an enticing language depending on your needs.
Anyways, at the time I realized… there’s a super cool domain extension: .rs
It’s expensive to purchase and only a few registrars offer it. What makes it so cool, is that .rs is the file extension for this language.
I realized cli.rs was available and decided to purchase it. Here’s the full idea:
You can find the GitHub project here.
I wanted to let anyone use the domain for their own projects… I wondered, how can I do this in a simple way?
If you find this interesting or helpful, consider subscribing.
1. DigitalOcean CLI
DigitalOcean is a hosting provider. I pointed the domain to them so that I could manage the DNS records here.
They offer a CLI tool to update DNS records from the command line!
2. GitHub Actions
With a CLI, I knew there was a way to automate this. So I created a GitHub action. It runs anytime there is a push to the master branch, and loops over files in the repo, and sets the DNS records.
3. Pull Requests
Tying it all together, I use GitHub pull requests for people to request a name under the domain. You can see an example PR here.
Anyone who wants to use, let’s say “myapp.cli.rs” just needs to fork the repo.
After that, you create a new file in the “domains” folder.
The file name is the subdomain you want. Ex “myapp”
Inside of the file, the only content is the CNAME value you want to point it to.
Once you make this file, you make a Pull Request, and I will approve it.
Even more automation
In theory, I could make the DNS record the moment someone makes a PR to the repo. In fact, I did this initially. The problem is, you can get spammers and other people who are messing around if you don’t add the small layer of approval to a system like this.
Using GitHub and DigitalOcean to enable sharing a domain through a repo was a fun idea. I hope this short story inspires more unique ideas to help out in other coding communities.