A composite action that starts a MockServer instance (HTTP(S) mock
server & proxy) for a CI job and waits until it is ready. It runs the official
mockserver/mockserver Docker image and polls the control-plane status endpoint.
Source of truth: this action is maintained in the MockServer monorepo at
.github/actions/setup-mockserverand mirrored here so it can be published to the GitHub Marketplace.
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start MockServer
id: mockserver
uses: mock-server/setup-mockserver@v1
with:
version: latest # or a release tag e.g. mockserver-6.1.0
port: '1080'
- name: Run tests against MockServer
run: |
curl -sf -X PUT "${{ steps.mockserver.outputs.url }}/mockserver/expectation" \
-H 'Content-Type: application/json' \
-d '{"httpRequest":{"path":"/hello"},"httpResponse":{"body":"Hello World"}}'
test "$(curl -s ${{ steps.mockserver.outputs.url }}/hello)" = "Hello World"| Input | Default | Description |
|---|---|---|
version |
latest |
MockServer Docker image tag (e.g. latest, mockserver-6.1.0). |
port |
1080 |
Host port to expose MockServer on (the container listens on 1080 internally). |
container-name |
mockserver |
Name for the started container. |
log-level |
INFO |
MockServer log level (INFO, WARN, DEBUG, TRACE). |
args |
'' |
Extra arguments appended to the MockServer command. Do not populate from untrusted input (e.g. PR titles) — values are word-split into the docker command. |
startup-timeout |
60 |
Max seconds to wait for readiness before failing. |
| Output | Description |
|---|---|
url |
Base URL of the running MockServer (http://localhost:<port>). |
- Runs on Linux runners (Docker pre-installed). The container is started with
--rm; the runner is torn down at job end, so no explicit cleanup step is required. - Versioning: use
@v1for the latest v1.x, or pin an exact release tag.