If you’re not using GitHub Actions you’re missing out!
This tool is a great way to catch any errors in the central place of the GitHub repo.
Catch errors early
Of course this is always second best, developers should do their due diligence locally first before pushing code:
Some of my favorites in that regard are:
- Set up syntax checking in your editor or IDE. As I am a Vim addict, I use this one.
- Make it easy to run your tests, I use a combination of a Makefile (example) and a .vimrc shortcut (nmap <leader>y :w<CR>:!pytest<CR>) – we will cover Makefiles soon in another article. For some common Vim tricks, check out this article.
- Use a pre-commit hook, for example to run black on your code before committing.
Some use cases
But then after pushing, having an automated workflow is awesome and saves a lot of time / resources:
Not only to run flake8 and pytest against your code, you can also set up further automations all based on certain events:
- Deploy your code to a cloud provider.
- Push your package to PyPI.
- Publish a docker image.
- Send an SMS.
- GitHub repo related things.
Here is a curated list of awesome things related to GitHub Actions.
How to set it up?
It’s really easy to set up:
- Create a .github/workflows folder structure (tip: use mkdir -p).
- Add one or more workflow yaml files – see the quick start guide.
Examples
To wrap this article up I show you 3 examples on our open source repos:
- Git stats > workflow file
- PyBites Books > workflow file
- Karmabot > workflow files (example multiple workflows)
Further resources: