If you build with a local model, the prompt is part of the code, and it can break like code does: a reworded instruction changes the answer, and nobody notices until users do. The fix is to test the prompt the same way you test code, in continuous integration. One published workflow does exactly that: it installs Ollama inside a GitHub Actions job, starts the server, pulls a model, and asks it a question, with no cloud API and no billing involved.
What the job needs
The workflow in the source guide runs on a self-hosted runner, not a GitHub-hosted one. Its requirements are a self-hosted GitHub Actions runner (Linux preferred), an NVIDIA GPU, the NVIDIA Container Toolkit for GPU passthrough, Docker if you want container isolation, and Ollama installed locally or inside a Docker container. A GitHub-hosted runner has no GPU, so a model would fall back to CPU and run slowly; the guide is written for a machine with a GPU that you register as your own runner.
Write the workflow file
Save this as .github/workflows/ollama-e2e.yml. It follows the source guide’s sample, with the model name and the two prompts kept exactly as the guide gives them:
name: Ollama CI Test
on:
workflow_dispatch:
jobs:
ollama-test:
runs-on: [self-hosted, gpu]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Install Ollama
run: curl -fsSL https://ollama.com/install.sh | sudo sh
- name: Start Ollama Server
run: |
ollama serve &
sleep 5
curl -s http://localhost:11434
- name: Pull Llama2 model
run: ollama pull llama2
- name: Run inference via CLI
run: ollama run llama2 "How do MicroVMs compare to Docker in CI/CD workflows?"
- name: Run inference via REST API
run: |
curl -s http://localhost:11434/api/generate -d '{
"model": "llama2",
"stream": false,
"prompt": "List risks of running privileged containers in CI pipelines"
}' | jq
The workflow_dispatch trigger means the job runs when you start it by hand from the Actions tab, which is the right trigger while you are proving the setup works. The server step starts Ollama in the background, waits five seconds, and then checks http://localhost:11434 answers. The local API base is http://localhost:11434/api, and local requests need no API key.
Add a pass-or-fail check
A job that only prints an answer cannot fail when the answer goes wrong. Add one step that checks the reply contains a word the correct answer must have. For the CLI prompt above, the answer compares MicroVMs with Docker, so it should mention Docker:
- name: Check the answer
run: ollama run llama2 "How do MicroVMs compare to Docker in CI/CD workflows?" | grep -qi docker
If the reply never mentions Docker, grep exits non-zero and the job fails, which is the signal you want: the prompt or the model changed, and the pull request should not merge until someone looks.
Try it: three checks from workflow to verdict
| Check | What you should see | What it means |
|---|---|---|
| Workflow file saved | .github/workflows/ollama-e2e.yml exists in the repo |
The job is defined and can be started by hand |
| Server answers | curl -s http://localhost:11434 returns a reply in the job log |
Ollama is serving inside the job |
| Answer checked | The check step passes because the reply mentions Docker | The model answered the prompt in CI |
Expected result. We checked the published GitHub Actions workflow in the Collabnix guide, which gives the runner requirements, the install and serve steps, and both prompt steps. We did not run a GitHub Actions job, install Ollama on a runner, or pull a model.
Limits
This only works as the guide describes it on a self-hosted runner with a GPU; on a GitHub-hosted runner there is no GPU to use, so a model would run on CPU and be slow. The llama2 model name and both prompts are the guide’s own examples, and a different model or prompt needs its own expected word in the check step. A word check is a smoke test, not a judgement of answer quality: a reply can mention Docker and still be wrong. We did not test any of this ourselves.
Sources
- Collabnix — CI for AI: Running Ollama + LLMs in GitHub Actions — self-hosted GPU runner requirements, the ollama-e2e.yml workflow, serve and pull steps, both prompt steps
- Ollama API introduction — local server at http://localhost:11434/api, local requests need no API key, read the answer from message.content
