TL;DR: in which I use HashiCorp’s Packer to automate installing and configuring many developer tools for my local dev environment on Windows. And detailing it on GitHub.
Why? My laptop frequently changes: either it breaks and after its repaired, I need to reinstall the tooling I need for software development. Or after X years, it has to be replaced (due to company policy).
Why not have an automated way to install and configure these tools?
It occured to me that Microsoft automatically installs and configures many development tools for its virtual machines on which GitHub Actions run. I want a similar experience, i.e., open a shell, execute commands to experiment without having first to worry about installing and configuring the tools/SDKs/Runtimes. In due time, that worry will come. Just not now.
Then, why not use the same approach for my laptop but at a smaller scale?
I’m spending more time recently working with GitHub actions and runners. I’ve found it helpful to test the GitHub Actions workflows on my local dev machine to get quick feedback and to also not populate my git histoy with “fix”-type commits.
I have docker running on my machine.
The workflows use only linux containers. `act` currently doesn’t support Windows or Mac.
Download and configure act and test initial run
Configure act to use non-default docker image with env vars and secrets
That runs-on tag tells the runner to use the ubuntu-latest image when executing the job.
When running the job locally, act has to somehow know which docker image to use when it sees the ubuntu-latest in the workflow yml file. This mapping exists in the act config file, $HOME/.actrc. The ubuntu-latest tag points to the docker image ghcr.io/catthehacker/ubuntu:act-latest
In a simplified way, act does the following:
reads the workflow yml
finds that the job should run on ubuntu-latest
looks up its config, sees ubuntu-latest is mapped to ghcr.io/catthehacker/ubuntu:act-latest
Now act will run the workflow on docker image localhost:5000/my-awesome-docker-image:0.1.0
If I want to run a custom runs-on tag against the act default images, replacing the above, i.e., localhost:5000/myawesomeselfhostedrunner:0.2.0 with ghcr.io/catthehacker/ubuntu:act-latest would also work: