Skip to content

mock-server/setup-mockserver

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Setup MockServer — GitHub Action

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-mockserver and mirrored here so it can be published to the GitHub Marketplace.

Usage

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"

Inputs

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.

Outputs

Output Description
url Base URL of the running MockServer (http://localhost:<port>).

Notes

  • 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 @v1 for the latest v1.x, or pin an exact release tag.

License

Apache-2.0

About

GitHub Action to start a MockServer (HTTP(S) mock server & proxy) in CI and wait until ready.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors