YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
MLOps CI/CD β GitHub Actions + Hugging Face Hub
Every push to main trains a model, evaluates it, and β only if it passes
an accuracy threshold β deploys it to Hugging Face Hub automatically.
How it works
push/PR to GitHub
β
βΌ
ββββββββ
β test β pytest sanity checks
ββββ¬ββββ
βΌ
ββββββββββββββββββββββ
β train_and_evaluate β prepare β train β evaluate
ββββββββ¬βββββββββββββββ β fails here if accuracy < params.yaml threshold
βΌ
βββββββββββββββββββββββ
β deploy_to_huggingface β only on push to main, only if gate passed
βββββββββββββββββββββββ re-trains + pushes model to your HF repo
Setup
1. Create a Hugging Face account + token
- Go to https://huggingface.co/settings/tokens
- Create a token with Write access
- Copy it β you'll paste it into GitHub next
2. Create the GitHub repo and push this code
cd mlops-simple
git init
git add .
git commit -m "Initial MLOps pipeline"
git branch -M main
git remote add origin https://github.com/<your-username>/<your-repo>.git
git push -u origin main
3. Add your HF token as a GitHub secret
In your GitHub repo: Settings β Secrets and variables β Actions β New repository secret
- Name:
HF_TOKEN - Value: the token from step 1
4. Add your target HF repo as a GitHub variable
Same page, Variables tab β New repository variable
- Name:
HF_REPO_ID - Value:
your-hf-username/your-model-name(e.g.mupalaniappan/breast-cancer-rf) β it'll be created automatically on first successful run if it doesn't exist yet.
5. Push to main
That's it β the workflow runs automatically. Check the Actions tab in
GitHub to watch it, and once deploy_to_huggingface finishes, your model is
live at https://huggingface.co/your-hf-username/your-model-name.
Adjusting the quality gate
Edit evaluate.min_accuracy in params.yaml. Anything scoring below that
never reaches Hugging Face β the deploy_to_huggingface job simply doesn't run.
Try it locally first (optional but recommended)
pip install -r requirements.txt
python src/prepare.py
python src/train.py
python src/evaluate.py
cat metrics.json
CI/CD deployment configured.