GitHub Actions: Automating Your Projectο
βοΈ GitHub Actions are tools that run automatically when certain things happen in your repository. They can test your code, build your docs, publish your package, and more.
In template-project, GitHub Actions live in the .github/workflows/ folder.
π€ What Is a GitHub Action?ο
A GitHub Action is a set of instructions that GitHub runs in response to events like:
Opening a pull request
Pushing new code
Creating a release tag
Each Action is defined in a .yml file inside .github/workflows/.
π§ͺ tests.yml: Run Your Tests Automaticallyο
When it runs:
Every time you open or update a pull request
What it does:
Sets up Python
Installs your dependencies
Runs
pytestto check your code
Why it matters:
Makes sure new code doesnβt break old code
Helps catch bugs early
π§± docs.yml: Test Your Documentation Buildο
When it runs:
On every pull request to
main
What it does:
Builds your documentation using Sphinx
Ensures you havenβt broken the docs accidentally
Why it matters:
Keeps your docs up to date with your code
Warns you if a bad docstring or config breaks the build
π docs_deploy.yml: Publish to GitHub Pagesο
When it runs:
After a pull request is merged into
main
What it does:
Rebuilds the documentation
Publishes the result to the
gh-pagesbranch
Why it matters:
You get a public documentation site (e.g.,
https://yourusername.github.io/your-repo)
π¦ pypi.yml: Publish a Package to PyPIο
When it runs:
When you push a GitHub release tag (e.g.,
v0.1.0)
What it does:
Builds your Python package
Uploads it to PyPI using secure GitHub credentials
Why it matters:
Makes your code
pip install-able by others
π οΈ How to Customize These Workflowsο
Look in .github/workflows/*.yml files. Youβll see sections like:
on:β what triggers the workflowjobs:β what steps to run
Each step can run shell commands or call existing actions (e.g., actions/setup-python).
If you want to:
Add coverage reports β modify
tests.ymlDeploy to a different site β update
docs_deploy.ymlUse conda instead of pip β swap the environment setup steps
β Summaryο
GitHub Actions in this template help you:
Test every pull request
Keep documentation working
Publish code to the web or to PyPI automatically
π‘ You donβt have to do anything to use them β they just work when you push code to GitHub!