I wrote my GitHub Action using Ruby, however out the box it requires a few libraries to run, which means every time it ran it took a moment to get setup.
At first, it was just a few seconds but as I started adding things on it suddenly was taking almost 60 seconds to get setup! 60 seconds felt like a lifetime when waiting for an Action to finish.
I jumped into investigating ways to make the setup a bit quicker. The trick I discovered was to use a prebuilt docker image for my GitHub Action with everything ready to go.
The first step I needed to make was to connect my Repository to DockerHub & have it build a new image each time I push to master.
This was actually super straightforward, I connected my GitHub account & pretty quickly I had it configured to perform a build every time master was updated.
The next thing I needed to do was to tell GitHub when someone runs my Action to download the Docker Image, this was a little tricky to debug but I found the following worked:
# action.yml runs: using: 'docker' image: 'docker://typoci/spellcheck-action' # When I want to check changes to my Dockerfile, I uncomment the following line: # image: 'Dockerfile'
Pulling down the image still took a moment, but the end result was my GitHub Action took ~15 seconds to setup. Awesome! I could probably get it down a bit more by optimising my Dockerfile a bit more, but for now I'm happy with it.