Skip to content

Commit 1158393

Browse files
committed
Support multiple entries in data and port options, and add extra-args option
1 parent 95c1361 commit 1158393

3 files changed

Lines changed: 23 additions & 15 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v3
13+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1414
- name: Use Node.js
15-
uses: actions/setup-node@v3
15+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
1616
with:
17-
node-version: 20
17+
node-version: 24
1818
- name: Run Mockoon CLI
19-
uses: mockoon/cli-action@v2
19+
uses: mockoon/cli-action@v3
2020
with:
2121
version: "latest"
22-
port: "3000"
23-
data-file: "https://raw.githubusercontent.com/mockoon/mock-samples/main/samples/generate-mock-data.json"
22+
port: "3001 3002"
23+
data-file: "https://raw.githubusercontent.com/mockoon/mock-samples/main/samples/generate-mock-data.json https://raw.githubusercontent.com/mockoon/mock-samples/main/samples/generate-mock-data.json"
24+
extra-args: "--faker-locale en_GB"
2425
- name: Make test call
2526
run: |
26-
curl -f -X GET http://localhost:3000/posts
27+
curl -f -X GET http://localhost:3001/posts
28+
curl -f -X GET http://localhost:3002/posts

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ This GitHub Action allows you to run Mockoon CLI in your workflows.
3333
Several parameters are available to customize the behavior of the action:
3434

3535
- The `version` of the CLI, default to `latest`.
36-
- The `data-file`, pointing to a [Mockoon data file](https://mockoon.com/docs/latest/mockoon-data-files/data-files-location/) stored in the repository.
37-
- A `port` on which the mock server will run, default to `3000`.
36+
- The `data-file`, pointing to one or more [Mockoon data file](https://mockoon.com/docs/latest/mockoon-data-files/data-files-location/) stored in the repository (or URLs), space separated: e.g., `file1.json file2.json`.
37+
- One or more `port` on which the mock server(s) will run, default to `3000`: e.g., `3000 4000`.
38+
- Additional `extra-args` to pass to Mockoon CLI: e.g., `--faker-locale en_GB --disable-routes users --env-vars-prefix MY_PREFIX_`.
3839

3940
```yaml
4041
name: Mockoon CLI demo
@@ -48,16 +49,18 @@ jobs:
4849
mockoon-cli-demo:
4950
runs-on: ubuntu-latest
5051
steps:
51-
- uses: actions/checkout@v3
52+
- uses: actions/checkout@v6
5253
- name: Run Mockoon CLI
53-
uses: mockoon/cli-action@v2
54+
uses: mockoon/cli-action@v3
5455
with:
5556
# Mockoon CLI version, default to 'latest'
5657
version: "latest"
5758
# Mockoon local data file or URL
5859
data-file: "./mockoon-data.json"
5960
# port, default to 3000
6061
port: 3000
62+
# extra arguments to pass to Mockoon CLI
63+
extra-args: "--faker-locale en_GB"
6164
- name: Make test call
6265
run: curl -X GET http://localhost:3000/endpoint
6366
```
@@ -69,7 +72,7 @@ This action is compatible with the following Mockoon CLI versions:
6972
| Mockoon CLI version | Action version |
7073
| ------------------- | -------------- |
7174
| <6.0.0 | v1 |
72-
| >=6.0.0 | v2 |
75+
| >=6.0.0 | >=v2 |
7376
7477
## CLI's documentation
7578

action.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ inputs:
88
required: true
99
default: "latest"
1010
data-file:
11-
description: "Mockoon CLI data file (local file or URL)"
11+
description: "Mockoon CLI data file (local file or URL, can be multiple, space separated, e.g., 'file1.json file2.json')"
1212
required: true
1313
port:
14-
description: "Mockoon CLI port"
14+
description: "Mockoon CLI port (can be multiple, space separated, e.g., '3000 4000')"
1515
required: true
1616
default: "3000"
17+
extra-args:
18+
description: "Extra arguments to pass to Mockoon CLI (e.g., '--faker-locale en_GB --disable-routes users --env-vars-prefix MY_PREFIX_')"
19+
required: false
1720
runs:
1821
using: "composite"
1922
steps:
@@ -22,4 +25,4 @@ runs:
2225
# use & to run in background for >4.0.0
2326
run: |
2427
npm install -g @mockoon/cli@${{ inputs.version }}
25-
mockoon-cli start --data ${{ inputs.data-file }} --port ${{ inputs.port }} &
28+
mockoon-cli start --data ${{ inputs.data-file }} --port ${{ inputs.port }} ${{ inputs.extra-args }} &

0 commit comments

Comments
 (0)