Prerequisites
Before you begin, ensure you have:- Completed the Running on Kubernetes guide
- WireMock Runner deployed and running in your Kubernetes cluster
- WireMock CLI installed and authenticated
- A GitHub account and repository for version control
- Git installed and configured locally
While this guide uses GitHub and GitHub Actions, the same principles apply to other Git platforms (GitLab, Bitbucket) and CI/CD tools (Jenkins, CircleCI, GitLab CI).
Initial setup
Set up development environment
If you have already completed the Recording Multiple APIs on Kubernetes guide,
you can skip this step as you will already have a development environment.
[development] suffix and generates a wiremock-development.yaml profile file that overlays your base wiremock.yaml configuration.
Note the base URLs from the output - you’ll use these to test your recorded endpoints in WireMock Cloud.
Set up staging environment
Create a staging environment that will serve as your pre-production testing ground:[staging] suffix and generates a wiremock-staging.yaml profile file. The staging environment will receive automated deployments from your CI/CD pipeline.
Initialize git repository
If you haven’t already, initialize Git in your project directory:.wiremock/wiremock.yaml- Base configuration with production mock APIs.wiremock/wiremock-development.yaml- Development environment overrides.wiremock/wiremock-staging.yaml- Staging environment overrides.wiremock/*/stub-mappings.yaml- Stub mappings for each mock API
Create GitHub Actions workflow
Create a GitHub Actions workflow that automatically pushes changes to staging when code is merged to the main branch. Create the workflow file:.github/workflows/deploy-staging.yml:
Configure GitHub secrets
Add your WireMock Cloud API token as a GitHub secret:- Go to your GitHub repository settings
- Navigate to Secrets and variables → Actions
- Click New repository secret
- Name:
WIREMOCK_API_TOKEN - Value: Your WireMock Cloud API token (find it at app.wiremock.cloud/account/security)
Update APIs via the workflow
Now that your environments and CI/CD pipeline are configured, you can start making changes.Sync development with the source project
Run the following to push all the configuration to the development environment in WireMock Cloud:Update APIs in development
Update the development APIs in Cloud via whatever means you wish e.g. manual editing in the UI, recording, scripting etc. See the recording on Kubernetes guide for details on recording multiple APIs simultaneously from within Kubernetes.Pull your changes from development
Pull the updated stub mappings from your development environment into your local project:.wiremock directory.
When pulling with a profile, only the stub mappings and API definition files are updated - the
wiremock.yaml configuration remains unchanged.Create a pull request
Create a new branch for your changes:- Go to your repository on GitHub
- Click Pull requests → New pull request
- Select your feature branch
- Add a description explaining the changes
- Create the pull request
Merge and Deploy
When the pull request is approved, merge it into the main branch:- Click Merge pull request on GitHub
- Confirm the merge
- Detect the changes in the
.wiremockdirectory - Run the deployment workflow
- Push the updated mock APIs to the staging environment
- Report the deployment status
Verify the Deployment
Check the GitHub Actions workflow to ensure it completed successfully:- Go to the Actions tab in your repository
- Click on the latest workflow run
- Verify all steps completed successfully
Troubleshooting
Workflow Fails with Authentication Error
If the GitHub Actions workflow fails with an authentication error:- Verify the
WIREMOCK_API_TOKENsecret is set correctly in GitHub - Check that your API token hasn’t expired
- Generate a new token at app.wiremock.cloud/account/security
Stub Mappings Not Updated After Push
If stub mappings don’t appear in WireMock Cloud after pushing:- Check the workflow logs for errors
- Verify the profile name matches your environment file
- Ensure the
cloud_idvalues in your profile file are correct
Additional Resources
- Learn about selective recording to record only specific services
- Set up branch-specific environments for feature branch testing