Hacker News new | past | comments | ask | show | jobs | submit login
Doing stupid stuff with GitHub Actions (devopsdirective.com)
380 points by spalas 13 days ago | hide | past | favorite | 45 comments





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/899...


Love 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

It uses the creation GitHub issues on the repo as the input method/trgger which is a pretty clever hack.


Yeah I have an article about profile README hacks using Actions here: https://simonwillison.net/2020/Jul/10/self-updating-profile-...

Oh nice, I saw that one on the front page the other day.

Didn't realize it was you -- great post!


Instead 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/


That sounds too straightforward, therefore not worth as many internet points...

(Thanks that's a nice share!)


Heh, 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.


I 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.

It's not often that I see things that are stupid but smart at the same time, so cool!

Genuine question: what is smart about this? What is the reasoning for not just writing the static assets by hand?

The 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 site.


Some 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.


It'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.

For anybody interested in playing around with and hacking on different CI / devops stuff I recently launched https://boxci.dev, which is a distributed CI service where the builds run on your own hardware, via a lightweight runner that just does coordination and runs build shell commands on bare metal, so it's a bit more hackable / flexible than (for instance) GH actions / Gitlab CI.

It's free to sign up and play around with it, and I'd love to get the feedback of any HNs who think this could be useful (I basically built it because it's the CI service I want to exist, and I think others might too).


> where the builds run on your own hardware

This is possible with GitHub Actions, too: https://docs.github.com/en/actions/hosting-your-own-runners/... (the place I work at uses it.)


This looks awesome.

As someone who's a bit newer to CI/CD, this solution would be ideal if you don't want to host Jenkins yourself right?

I just give you access to my GitHub repos, install the agent then whenever I commit something into GitHub, the agent will see this and perform the task/pipeline right?

Similarly to how Jenkins works, except I don't need to install Jenkins - I just install the agent instead.


Exactly right!

And just to emphasise, even the agents are totally ephemeral and don't require much management effort on your side - you can install and spin them up/down on any machine at any time just through shell commands and the service automatically manages this agent pool and sends builds to it - no manual steps at all. If no agents are running, builds just sit in a queue.

If you'd be interested in playing around with it and have any questions, please feel free to email me (email's in my profile).


neat. Looks similar to https://buildkite.com .

Yep! We've been doing this at Buildkite for six years now. We're lucky to have a lot of fantastic customers who have helped us learn over the years what makes a great hybrid SaaS/self-hosted CI solution.

The "Holiday Reminder" could actually send a somewhat puzzling notification about you needing to check out the GitHub pipeline for a production failure. I would for sure forget about even setting it up and would shit my pants on New Year's Eve... and then have a good laugh on myself.

Haha, good point... I have another 5 months to fully forget that I ever set this up.

The name of the action does get included in the email notification so hopefully I'll be able to decypher it, even after some NYE celebration champagne!


You could set up a weekly failing job that reminds you ;)

I rarely see a sense of humor on HN. It’s a nice surprise and I hope to see more of it. Nice job!

I'm glad you enjoyed it!

I figured if I was going to learn a new tool, I might as well have some fun along the way!


Reminds me of my first year in college, when we'd log into each other's machines at the computer lab for some intro to computing class, and launch a fork-bomb script that simply launched itself twice, quickly rendering the machine useless. The tricky part was to test it without halting your own machine, as a newbie programmer and Unix user.

Haha - We have it too easy these days and can just spin up a VM with Virtual Box (or similar) to test stuff like this.

I've used GH Actions to replicate LinkedIn's Endorsements feature on their new Profile Readme feature: https://github.com/sw-yx/sw-yx

Unlike the authoer, I haven't found Github Actions very intuitive to work with :)

I've asked this before on a similar post, maybe someone here knows. Has anyone managed to get a Pre-Release to track Master using Github Actions? I can't seem to find a working example that does this (and I can't seem to cobble one together myself)

There are a few things that are seemingly intentionally left out of GitHub Actions... like you can create new Releases on a push, but there is no direct way to delete/update a release with fresh builds.

I know you can just get build artifacts - but those are not publicly available and hard to link people to.


I think you could build on this action https://github.com/actions/github-script/ which provides a JS client for the GitHub API.

It looks like it supports all of the API routes you would need including:

https://github.com/actions/github-script/blob/b507739f17c210...

To actually perform the release update.


it's strange to me this isn't a first class feature

Thanks for the tip. I don't really know JS so I may dig into this if it becomes a major burden. For the time being I'll just manually delete the prerelease between pushes


Alternative idea for exponential action: action that creates another action (automate a headless browser, or maybe github has an api for that?). Kill switch: delete the repo :)

The real question is, are Github Actions Turing complete?

Yes you can run arbitrary code in them.

With the new GitHub profile README feature, GitHub Actions gained a lot of traction. I'm using it to automatically display my latest blog post [1].

[1] https://darekkay.com/blog/github-profile-readme/


I was reading all the comments and found it really interesting. Thanks for the post.

I work on a product similar to Github Actions: https://cto.ai/ but there is a built in interaction layer for interacting from Slack channels.

nice site, it's clean

Thanks!

Most of the credit goes to Alex Shpak (https://github.com/alex-shpak/) who created the "Book" theme for hugo (https://themes.gohugo.io/hugo-book/).


It's nice but it could be cleaner, by dropping the sidebar, and constraining the width of prose. See "Why is the text on your site so narrow? It wastes screen space." here: http://www.paulgraham.com/gfaq.html

Is it any better to use images for styling buttons instead of CSS?

Also loaded very quickly for me. Static sites FTW!

...and its hosted on an f1-micro instance! (https://devopsdirective.com/posts/2020/03/load-testing-f1-mi...)

Almost all of the load is handled by CloudFlare though.


Just curious - why didn't you decide to serve the site from object storage?

Mostly because I knew I wanted to play around with trying out different configurations, testing performance, etc...

If I didn't have those secondary goals, I would have either:

1) Hosted on Netlify

OR

2) Hosted in an S3 / GCS bucket


cool - and the micro instance is free anyway



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: