Automate workflow deployments and runs using the mixtrain CLI in GitHub Actions. Deploy updated workflows on every push, trigger training runs on merge, and gate PRs on evaluation results.
Prerequisites
- Generate an API key in the mixtrain dashboard under Settings > API Keys.
- Add the key as a GitHub secret named
MIXTRAIN_API_KEYin your repository settings (Settings > Secrets and variables > Actions).
Basic Example
This workflow deploys and runs a mixtrain workflow whenever you push to main:
name: mixtrain
on:
push:
branches: [main]
jobs:
train:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mixtrain
run: pip install mixtrain
- name: Deploy and run workflow
env:
MIXTRAIN_API_KEY: ${{ secrets.MIXTRAIN_API_KEY }}
run: |
mixtrain workflow create ./workflow-dir/ --name my-workflow
mixtrain workflow run my-workflow --gpu A100The CLI authenticates automatically when MIXTRAIN_API_KEY is set as an environment variable.
Update an Existing Workflow
If your workflow already exists and you want to update its files on each push, use workflow edit --add instead of create:
- name: Update and run workflow
env:
MIXTRAIN_API_KEY: ${{ secrets.MIXTRAIN_API_KEY }}
run: |
mixtrain workflow edit my-workflow --add ./workflow-dir/
mixtrain workflow run my-workflow --gpu A100Run on Pull Request
Trigger a run on PR events and use --detach if you don't need to wait for completion in CI:
name: mixtrain PR check
on:
pull_request:
branches: [main]
jobs:
eval:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mixtrain
run: pip install mixtrain
- name: Run evaluation
env:
MIXTRAIN_API_KEY: ${{ secrets.MIXTRAIN_API_KEY }}
run: |
mixtrain workflow edit my-eval --add ./eval/
mixtrain workflow run my-eval --input '{"ref": "${{ github.sha }}"}'Since workflow run exits with a non-zero code on failure, the GitHub Actions step will fail if the workflow run fails.
Wait for Completion
By default, workflow run streams logs and waits for the run to finish. This means your CI job will:
- Pass (exit 0) if the workflow run completes successfully
- Fail (exit 1) if the workflow run fails
If you want to start a run without waiting, use --detach:
- name: Start run (fire and forget)
env:
MIXTRAIN_API_KEY: ${{ secrets.MIXTRAIN_API_KEY }}
run: mixtrain workflow run my-workflow --detachPassing Inputs
Pass structured inputs to your workflow run using --input with JSON or a file path:
- name: Run with parameters
env:
MIXTRAIN_API_KEY: ${{ secrets.MIXTRAIN_API_KEY }}
run: |
mixtrain workflow run my-workflow \
--input '{"epochs": 10, "learning_rate": 0.001}' \
--gpu A100 \
--timeout 3600CLI Reference
See the full CLI workflow reference for all available commands and options.