You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
├── mesh.json # API Mesh definition (commit your own)
31
31
├── .env # Optional runtime variables used by mesh.json
32
+
├── tests/
33
+
│ └── newman/
34
+
│ ├── collection.json # Postman collection export
35
+
│ ├── environment_staging.json # Environment variables for staging
36
+
│ └── environment_production.json # Environment variables for production
32
37
└── README.md # This documentation
33
38
```
34
39
@@ -69,6 +74,27 @@ Add any extra secrets referenced by your mesh (for custom resolvers, HTTP header
69
74
70
75
If these variables are present, the workflow writes them to `.env` before running `aio api-mesh:*`. If they are empty, the pipeline falls back to any `.env` file committed in the repository or skips the flag entirely.
71
76
77
+
#### How Environment Variable Injection Works
78
+
79
+
The workflow uses an internal environment variable `AIO_ENV_FILE` to handle the `.env` materialization:
80
+
81
+
1.**Branch detection** — The workflow identifies the current branch (`staging` or `production`).
82
+
2.**Variable mapping** — If `ENV_STAGE` or `ENV_PROD` is set, its contents are stored in the `AIO_ENV_FILE` workflow environment variable.
83
+
3.**File materialization** — If `AIO_ENV_FILE` is not empty, the workflow writes its contents to `.env` in the repository root with restricted permissions (`chmod 600`).
84
+
4.**Flag computation** — The "Compute Mesh Credential Flags" step checks for the presence of `.env` and automatically appends `--env .env` to the mesh CLI commands.
85
+
86
+
This approach allows you to:
87
+
- Keep sensitive environment values out of Git by storing them as GitHub Variables.
88
+
- Override a committed `.env` file with branch-specific values.
89
+
- Support multi-line `.env` payloads (GitHub Variables preserve newlines).
90
+
91
+
**Example `ENV_STAGE` variable content:**
92
+
```
93
+
RESOLVER_API_KEY=sk-staging-xxx
94
+
BACKEND_URL=https://api.staging.example.com
95
+
DEBUG=true
96
+
```
97
+
72
98
---
73
99
74
100
### Runner image requirements
@@ -171,6 +197,78 @@ Extend or reorder steps as needed (e.g., run linting/tests before deployment, se
171
197
172
198
---
173
199
200
+
## Newman Testing Configuration
201
+
202
+
The template includes a reusable testing workflow (`.github/workflows/tests.yaml`) that runs Newman-based regression tests after each successful deployment. Tests are **optional** — the workflow gracefully skips execution if the required files are not present.
├── environment_staging.json # Environment variables for staging branch
211
+
└── environment_production.json # Environment variables for production branch
212
+
```
213
+
214
+
### File Details
215
+
216
+
| File | Description |
217
+
| --- | --- |
218
+
|`collection.json`| Exported Postman collection containing your API tests. Export from Postman using **Collection → Export → Collection v2.1**. |
219
+
|`environment_staging.json`| Postman environment export with variables for staging (e.g., `baseUrl`, API keys). The filename must match `environment_staging.json`. |
220
+
|`environment_production.json`| Postman environment export with variables for production. The filename must match `environment_production.json`. |
221
+
222
+
### How It Works
223
+
224
+
1. After the `deploy` job completes successfully, the `tests` job is triggered.
225
+
2. The workflow checks for `tests/newman/collection.json` — if missing, tests are skipped.
226
+
3. The workflow looks for `tests/newman/environment_<branch>.json` based on the current branch — if missing, tests are skipped.
227
+
4. If both files exist, Newman runs inside a Docker container (`postman/newman_alpine33`) and executes all requests in the collection against the branch-specific environment.
228
+
229
+
### Creating Your Test Files
230
+
231
+
1.**Export your Postman collection:**
232
+
- Open Postman and select your collection.
233
+
- Click the **...** menu → **Export** → **Collection v2.1** → Save as `collection.json`.
234
+
235
+
2.**Export your Postman environments:**
236
+
- Go to **Environments** in Postman.
237
+
- Select the environment → **...** → **Export** → Save as `environment_staging.json` or `environment_production.json`.
> **Tip:** Avoid committing sensitive values in environment files. Use Postman's variable substitution with placeholder values and override them via GitHub Secrets if needed.
269
+
270
+
---
271
+
174
272
## Customizing the Template
175
273
176
274
-**Additional environments** – duplicate the branch/secrets mapping block and add new branches like `qa` or `dev` with their own credential sets.
0 commit comments