A GitHub Actions Workflow for ML
Run lint, tests, and training on every push.
A GitHub Actions Workflow for ML is a free MLOps Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MLOps Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Meet GitHub Actions
GitHub Actions runs your scripts on GitHub's servers whenever something happens in your repo, like a push, so you never run CI by hand again. ⚙️
Workflows Live in YAML
A workflow is a YAML file inside .github/workflows. GitHub reads it and follows your instructions step by step on each trigger.
.github/workflows/ml.ymlThe on: Trigger
The on key says when to run. Here it fires on every push, so each commit kicks off your ML checks automatically.
on:
push:
branches: [main]Jobs Run the Work
A workflow holds one or more jobs. Each job runs on a fresh virtual machine, so your pipeline always starts from a clean, predictable state.
jobs:
build:
runs-on: ubuntu-latestSteps Are the Recipe
Inside a job, steps run in order from top to bottom. Each step is either a reusable action or a plain shell command you write.
Check Out Your Code
The first step almost always uses the checkout action to copy your repo onto the runner. Without it, the machine has no code to test.
- uses: actions/checkout@v4Set Up Python
For an ML repo you set up Python next, choosing the exact version so the runner matches the environment your team trains in.
- uses: actions/setup-python@v5
with:
python-version: "3.11"Install Dependencies
Then you install your pinned packages so the runner has the same libraries you use locally. This makes every CI run reproducible.
- run: pip install -r requirements.txtLint, Then Test
Now add the ML checks: a lint step to catch style issues, then pytest to run your data and model tests on the fresh runner.
- run: ruff check .
- run: pytestTrain on a Sample
A final step can train on a small sample to prove the pipeline works end to end, keeping CI fast while still exercising real code.
- run: python train.py --sample 1000Watch It Run
Push your YAML and open the Actions tab. GitHub shows a live log of each step, with a green check when your ML pipeline passes. ✅
Quick Check
Where must a GitHub Actions workflow file live to be picked up?
Recap
A workflow YAML in .github/workflows defines triggers, jobs, and ordered steps. For ML you check out code, set up Python, install deps, then lint, test, and train.
Frequently asked questions
Is the “A GitHub Actions Workflow for ML” lesson free?
Yes — the full text of “A GitHub Actions Workflow for ML” is free to read here on the web, and the MLOps Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MLOps Academy course, upgrade to CoddyKit PRO.
What will I learn in “A GitHub Actions Workflow for ML”?
Run lint, tests, and training on every push. You practise MLOps Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start MLOps Academy?
No prior experience is required. MLOps Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “A GitHub Actions Workflow for ML” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this MLOps Academy lesson?
Yes. Every MLOps Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- What CI/CD Means for Models
- A GitHub Actions Workflow for ML
- Gate Merges on Model Quality
- Build and Push the Image on Release