5 ms·
I really enjoyed Jonty Wareing's hack recently where he built a static site generator inside a GitHub Action that works by doing the following: 1. Spin up a Py
by simonw 6y ago
I really enjoyed Jonty Wareing's hack recently where he built a static site generator inside a GitHub Action that works by doing the following:
1. Spin up a Python Flask web server on localhost
2. Run "wget --mirror" against it to crawl the site and save it as static files
3. Publish the resulting static files to GitHub Pages
The workflow is here. It's genius: https://github.com/pubstandards/pubstandards-london/blob/89989bd3e3e2391425bc8e76055e90892635ec5a/.github/workflows/build.yml https://github.com/pubstandards/pubstandards-london/blob/899...
- gjulianm 6y agoIt's not often that I see things that are stupid but smart at the same time, so cool!
- buzzerbetrayed 6y agoGenuine question: what is smart about this? What is the reasoning for not just writing the static assets by hand?
- withinboredom 6y agoSome possibilities come to mind: 1. because the people writing the content are not developers. 2. there’s dynamic content, but when you know you’re going to get a large influx of traffic from a single region/event, you can precompute it for a short period.
- simonw 6y agoThe site already existed, but they wanted to serve it statically to save on complexity and money. If you dig into the repo you'll see that it's maintained using a YAML file, which is a smart way to deal with small sites that still contain structured content. I do the same thing for my https://github.com/simonw/museums https://github.com/simonw/museums site.
- gjulianm 6y agoIt's smart because it's a solution to a problem (freezing dynamic content) in one line of code, the wget command. It should work for most cases and it's easy to understand and deploy.
- spalas 6y agoLove it! I have seen people doing fun things with GitHub Actions for the new GitHub profile readme feature as well. This community chess game is one of my favorites https://github.com/timburgan/timburgan https://github.com/timburgan/timburgan It uses the creation GitHub issues on the repo as the input method/trgger which is a pretty clever hack.
- simonw 6y agoYeah I have an article about profile README hacks using Actions here: https://simonwillison.net/2020/Jul/10/self-updating-profile-readme/ https://simonwillison.net/2020/Jul/10/self-updating-profile-...
- spalas 6y agoOh nice, I saw that one on the front page the other day. Didn't realize it was you -- great post!
- thom 6y agoHeh, I worked on a site for a brand during the 2006 World Cup that did basically exactly this (although a PHP site, and a slightly rickety manual build process). They had bought pitchside advertising to be shown during the final, and anticipating enormous traffic which sadly never materialized. But we totally could have handled it! Other over-optimisations on the same project included going all the way and including functionality to handle drawn lots as tie-breakers. This also never happened.
- neurostimulant 6y agoInstead of wget-ing localhost, maybe it's better to use Frozen-Flask[1] instead. I use it to implement my own static site generator for my personal website and it's working great. [1] https://pythonhosted.org/Frozen-Flask/ https://pythonhosted.org/Frozen-Flask/
- yebyen 6y agoThat sounds too straightforward, therefore not worth as many internet points... (Thanks that's a nice share!)
- jcun4128 6y agoI was trying to look into GitHub actions but didn't really understand it. I just straight up called CLI commands eg. $git commit -m "..." and ran those after I put a key(in my case on a pi) and it does commits by CRON. I was just publishing sensor data to my GitHub readme. But it's cool that it works.