I've spent today re-organising the Github Actions I use to build and deploy my static site generator and it's plugins. There are a lot of repos and the workflows are all quite similar but they tend to diverge over time and it gets quite complicated to manage.
The solution was to extract any steps that were longer than a couple of lines of bash into seperate bash scripts. Then put all these in a scripts repo. The workflows now clone this repo at the start and use the scripts within as the workflows unfolds. The big advantage is the scripts are in one place, no code duplication, nothing to go out of sync. When I change the scripts all the repos get that change.
I can't tell you how much better that is. Also the workflows have become much much shorter so they are much easier to reason about. When you start out on a project it's the sort of thing that isn't always obvious. It's only after creating the workflow many times over that you see the commonality between them. It takes several iterations to refactor so there is code that can be reused in many places, rather than lots of custom bits of logic everywhere.
These sorts of improvements are great, they feel stabilising. #