Skip to content

Commit e331682

Browse files
author
Genevieve Nuebel
committed
Update docs
1 parent c807912 commit e331682

6 files changed

Lines changed: 130 additions & 19 deletions

.github/workflows/on-push-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- 'v20111101/**'
88
- 'v20250224/**'
99
repository_dispatch:
10-
types: [manual_push_to_master]
10+
types: [automated_push_to_master]
1111

1212
jobs:
1313
# Check for skip-publish flag in commit message. This allows skipping publish/release for specific scenarios,

.github/workflows/openapi-generate-and-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ jobs:
208208
uses: peter-evans/repository-dispatch@v2
209209
with:
210210
token: ${{ steps.generate_token.outputs.token }}
211-
event-type: manual_push_to_master
211+
event-type: automated_push_to_master
212212

213213
- name: Slack notification
214214
uses: ravsamhq/notify-slack-action@v2

docs/Adding-a-New-API-Version.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Document Purpose**: Step-by-step guide for adding support for a new API version (e.g., `v20300101`) to the mx-platform-node repository.
44

5-
**Last Updated**: January 29, 2026
5+
**Last Updated**: February 18, 2026
66
**Time to Complete**: 30-45 minutes
77
**Prerequisites**: Familiarity with the multi-version architecture (see [Multi-Version-SDK-Flow.md](Multi-Version-SDK-Flow.md))
88

@@ -152,6 +152,8 @@ version_directory:
152152

153153
This workflow is automatically triggered by the OpenAPI repository to generate and push SDKs for all versions in parallel.
154154

155+
**Note**: The existing infrastructure handles config file artifact upload/download between Generate and Process-and-Push jobs automatically. You only need to add the version-to-config mapping below — the artifact pipeline will pick up your new config file without additional changes.
156+
155157
**Location 1: Version-to-config mapping**
156158

157159
In the `Setup` job's `Set up matrix` step, find the section with the version-to-config mapping and add an `elif` branch for your new version:
@@ -228,9 +230,11 @@ on:
228230
- 'v20111101/**'
229231
- 'v20250224/**'
230232
- 'v20300101/**' # NEW
233+
repository_dispatch:
234+
types: [automated_push_to_master] # No changes needed here
231235
```
232236

233-
This ensures the workflow triggers when changes to your version directory are pushed to master.
237+
This ensures the workflow triggers when changes to your version directory are pushed to master. The `repository_dispatch` trigger does not need modification — it is used by `openapi-generate-and-push.yml` to trigger this workflow after automated pushes, and works regardless of which version directories changed.
234238

235239
**Location 3: Add publish job for new version**
236240

docs/Multi-Version-SDK-Flow.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Document Purpose**: Quick-reference guide to the multi-version SDK generation, publishing, and release system. This is your entry point to understanding how the system works.
44

5-
**Last Updated**: January 28, 2026
5+
**Last Updated**: February 18, 2026
66
**Read Time**: 5-10 minutes
77
**Audience**: Anyone joining the team or needing a system overview
88

@@ -37,7 +37,7 @@ OpenAPI spec changes → `openapi-generate-and-push.yml` generates SDK → commi
3737
**What Happens**:
3838
1. `openapi-generate-and-push.yml` generates all specified versions in parallel
3939
2. All generated files committed to master
40-
3. `on-push-master.yml` automatically triggered by the push
40+
3. `openapi-generate-and-push.yml` sends a `repository_dispatch` event (`automated_push_to_master`) to trigger `on-push-master.yml` (required because `GITHUB_TOKEN` pushes don't trigger other workflows)
4141
4. `on-push-master.yml` handles serial publish/release with version gating
4242

4343
**Key Details**: See [Workflow-and-Configuration-Reference.md](Workflow-and-Configuration-Reference.md#flow-1-automatic-multi-version-generation-repository-dispatch)
@@ -83,7 +83,7 @@ sequenceDiagram
8383
Gen->>Push: Commit to master<br/>Update CHANGELOG.md
8484
deactivate Gen
8585
86-
Push->>+OnPush: Push event triggers
86+
Push->>+OnPush: repository_dispatch<br/>(automated_push_to_master)
8787
OnPush->>OnPush: Check skip-publish flag
8888
OnPush->>OnPush: Serial: v20111101 publish
8989
OnPush->>npm: npm publish v2.x.x

docs/Troubleshooting-Guide.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Document Purpose**: Quick reference for diagnosing and fixing issues in the multi-version SDK generation, publishing, and release workflows.
44

5-
**Last Updated**: January 29, 2026
5+
**Last Updated**: February 18, 2026
66
**Audience**: Developers debugging workflow failures
77

88
---
@@ -289,6 +289,33 @@ fatal: A release with this tag already exists
289289

290290
---
291291

292+
### Generated Files Placed in Nested Subdirectory
293+
294+
**Symptom**: After automated generation, SDK files appear at `v20111101/generated-v20111101/api.ts` instead of `v20111101/api.ts`
295+
296+
**Cause**: The `Process-and-Push` job in `openapi-generate-and-push.yml` downloads generated artifacts and moves them into the version directory. If the version directory already exists (from a prior commit), `mv` places the source *inside* the existing directory as a subdirectory rather than replacing it.
297+
298+
**Solution**: Already fixed in `openapi-generate-and-push.yml`. The workflow now runs `rm -rf ./$VERSION` before `mv` to ensure the target directory doesn't exist, so the move replaces rather than nests. If you see this issue, verify the workflow includes the `rm -rf` step before the `mv` command in the Process-and-Push job.
299+
300+
---
301+
302+
### Version Bump Not Applied During Automated Generation
303+
304+
**Symptom**: Automated generation completes but the version in `package.json` didn't increment (stays at the previous version)
305+
306+
**Cause**: The `version.rb` script argument was quoted incorrectly in the workflow. Passing `"$VERSION"` (with surrounding quotes in the shell script) causes bash to pass the literal string `$VERSION` instead of its value, so `version.rb` receives an unrecognized bump type and silently fails.
307+
308+
**Solution**: Already fixed in `openapi-generate-and-push.yml`. The `$VERSION` variable is now passed unquoted to `version.rb`. If you see this issue, verify the workflow calls `version.rb` with `$VERSION` (not `"$VERSION"`):
309+
```bash
310+
# Correct
311+
NEW_VERSION=$(ruby .github/version.rb $VERSION ${{ matrix.config_file }})
312+
313+
# Wrong — passes literal string
314+
NEW_VERSION=$(ruby .github/version.rb "$VERSION" ${{ matrix.config_file }})
315+
```
316+
317+
---
318+
292319
### Workflow Not Triggering on Push
293320

294321
**Symptom**: Merged a PR with changes to `v20111101/` directory, but `on-push-master.yml` didn't run
@@ -298,6 +325,7 @@ fatal: A release with this tag already exists
298325
- Changes were not actually in the version directory
299326
- Commit was made to wrong branch
300327
- Workflow file has syntax error
328+
- (Automated flow only) The push was made with `GITHUB_TOKEN`, which does not trigger `push` events for other workflows
301329

302330
**Solutions**:
303331
1. Verify path filter syntax is correct:
@@ -308,6 +336,8 @@ fatal: A release with this tag already exists
308336
paths:
309337
- 'v20111101/**' # Correct format
310338
- 'v20250224/**'
339+
repository_dispatch:
340+
types: [automated_push_to_master]
311341
```
312342
2. Check what files were actually changed:
313343
```bash
@@ -322,6 +352,7 @@ fatal: A release with this tag already exists
322352
```bash
323353
ruby -e "require 'yaml'; puts YAML.load(File.read('.github/workflows/on-push-master.yml'))"
324354
```
355+
5. **For automated flows**: Verify that `openapi-generate-and-push.yml` sends a `repository_dispatch` event after pushing. The `push` trigger only works for manual PR merges. Automated pushes from workflows use `GITHUB_TOKEN`, which does not trigger other workflows — the generate workflow must send an explicit `repository_dispatch` (type: `automated_push_to_master`) using a GitHub App token.
325356

326357
---
327358

@@ -347,6 +378,36 @@ git commit -m "Migrate SDK structure skip-publish"
347378

348379
---
349380

381+
### Skip-Publish Check Fails with Bash Error
382+
383+
**Symptom**: The `check-skip-publish` step in `on-push-master.yml` errors with something like `SDK: command not found` (exit code 127), and downstream jobs skip unexpectedly
384+
385+
**Cause**: The commit message contains double quotes (e.g., `Revert "Generated SDK versions: v20111101"`). If the workflow uses inline `${{ }}` interpolation to assign the commit message, the inner quotes close the outer quotes in bash, causing the remaining text to be interpreted as commands.
386+
387+
**Example of broken pattern**:
388+
```yaml
389+
# BROKEN - double quotes in commit message break this
390+
COMMIT_MSG="${{ github.event.head_commit.message }}"
391+
```
392+
393+
**Solution**: The workflow should use an `env:` block to pass the commit message safely:
394+
```yaml
395+
- name: Check for [skip-publish] flag in commit message
396+
id: check
397+
env:
398+
COMMIT_MSG: ${{ github.event.head_commit.message }}
399+
run: |
400+
if [[ "$COMMIT_MSG" == *"[skip-publish]"* ]]; then
401+
echo "skip_publish=true" >> $GITHUB_OUTPUT
402+
else
403+
echo "skip_publish=false" >> $GITHUB_OUTPUT
404+
fi
405+
```
406+
407+
This fix is already applied to `on-push-master.yml`. If you see this error, verify that the workflow is using the `env:` block pattern and not inline interpolation.
408+
409+
---
410+
350411
### Version.rb Script Errors
351412

352413
#### Error: "Version directory parameter required"

docs/Workflow-and-Configuration-Reference.md

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Document Purpose**: Detailed technical reference for the multi-version SDK generation, publishing, and release workflows. Covers implementation details, configuration files, and system architecture.
44

5-
**Last Updated**: January 29, 2026
5+
**Last Updated**: February 18, 2026
66
**Audience**: Developers who need to understand or modify the implementation
77

88
---
@@ -81,14 +81,21 @@ strategy:
8181
8282
6. **Upload Artifacts**
8383
- Upload generated SDK to workflow artifact storage
84+
- Upload bumped config file as separate artifact (config file version bump happens on Generate runner, but Process-and-Push runs on a different runner with a fresh checkout — without this, the version bump would be lost)
8485
- Allows atomic multi-version commit after all matrix jobs complete
8586
8687
#### Step 3: Post-Generation Processing (After All Matrix Jobs Complete)
8788
8889
1. **Download Artifacts**
8990
- Retrieve generated SDKs for all versions from artifact storage
91+
- Retrieve config file artifacts and restore them to `openapi/` directory
92+
- Clean up config artifact directories (`rm -rf ./generated/config-*`) to prevent them from being committed
9093
91-
2. **Track Generated Versions**
94+
2. **Move Generated Files to Version Directories**
95+
- Remove existing version directory contents before moving: `rm -rf ./$VERSION` then `mv` generated files into place
96+
- This prevents the generated files from being placed in a nested subdirectory (e.g., `v20111101/generated-v20111101/` instead of `v20111101/`)
97+
98+
3. **Track Generated Versions**
9299
- Record which directories were actually generated
93100
- Used by CHANGELOG automation to add entries only for generated versions
94101
@@ -129,15 +136,19 @@ strategy:
129136
130137
#### Step 5: Automatic Publish and Release (via on-push-master.yml)
131138
132-
**Architecture**: After `Process-and-Push` completes and pushes to master, the automatic `on-push-master.yml` workflow is triggered by GitHub's push event.
139+
**Architecture**: After `Process-and-Push` completes and pushes to master, it explicitly triggers `on-push-master.yml` via a `repository_dispatch` event (type: `automated_push_to_master`).
140+
141+
**Why `repository_dispatch` instead of relying on the push event?** GitHub's security model prevents workflows triggered by `GITHUB_TOKEN` from triggering other workflows. Since `openapi-generate-and-push.yml` pushes to master using `GITHUB_TOKEN`, that push does **not** trigger `on-push-master.yml`'s `push` event. To solve this, `openapi-generate-and-push.yml` generates a GitHub App token (via `tibdex/github-app-token@v1`) and uses it to send a `repository_dispatch` event (via `peter-evans/repository-dispatch@v2`), which does trigger `on-push-master.yml`.
142+
143+
**Note**: The `push` trigger on `on-push-master.yml` still exists and works for manual PR merges — only automated pushes from workflows need the `repository_dispatch` workaround.
133144
134145
**Why This Architecture?**
135146
- Separates concerns: `openapi-generate-and-push.yml` owns generation, `on-push-master.yml` owns publishing
136147
- Enables consistent publish logic: All publishes (whether from automated generation or manual PR merge) go through the same workflow
137148
- Prevents duplicate publishes: Manual generate.yml + PR merge only triggers publish once (via on-push-master.yml)
138149
139150
**Process** (handled by `on-push-master.yml`):
140-
1. Detect-changes job uses `dorny/paths-filter@v2` to identify which version directories changed (v20111101/**, v20250224/**)
151+
1. Detect-changes job uses `dorny/paths-filter@v2` to identify which version directories changed (v20111101/**, v20250224/**). For `repository_dispatch` events, uses `base: HEAD~1` to compare against the previous commit (push events use default `before`/`after` automatically).
141152
2. Check-skip-publish job detects if `[skip-publish]` flag is in commit message
142153
3. For each version with path changes (output by detect-changes):
143154
- Publish job: Call `publish.yml` with version-specific directory (only if paths modified)
@@ -339,8 +350,13 @@ publish-v20250224:
339350

340351

341352

342-
### Trigger
343-
Push to `master` branch with changes in version-specific directories (`v20111101/**` or `v20250224/**`)
353+
### Triggers
354+
355+
`on-push-master.yml` responds to two trigger types:
356+
1. **`push`** — activated when changes are pushed to `master` (e.g., PR merges)
357+
2. **`repository_dispatch`** (type: `automated_push_to_master`) — activated by `openapi-generate-and-push.yml` after it pushes generated SDK files to master (needed because `GITHUB_TOKEN` pushes don't trigger `push` events for other workflows)
358+
359+
Both triggers require changes in version-specific directories (`v20111101/**` or `v20250224/**`) to proceed to publishing.
344360

345361
### Skip-Publish Safety Mechanism
346362
Include `[skip-publish]` in commit message to prevent publish/release for this push.
@@ -358,15 +374,21 @@ Include `[skip-publish]` in commit message to prevent publish/release for this p
358374
**Job**: `check-skip-publish`
359375

360376
```yaml
361-
- name: Check for skip-publish flag
377+
- name: Check for [skip-publish] flag in commit message
378+
id: check
379+
env:
380+
COMMIT_MSG: ${{ github.event.head_commit.message }}
362381
run: |
363-
if [[ "${{ github.event.head_commit.message }}" == *"[skip-publish]"* ]]; then
382+
if [[ "$COMMIT_MSG" == *"[skip-publish]"* ]]; then
364383
echo "skip_publish=true" >> $GITHUB_OUTPUT
384+
echo "🚫 [skip-publish] flag detected - skipping all publish/release jobs"
365385
else
366386
echo "skip_publish=false" >> $GITHUB_OUTPUT
387+
echo "✅ No skip flag - proceeding with publish/release"
367388
fi
368389
```
369390

391+
- Uses `env:` block to safely pass commit message (avoids bash errors when commit messages contain double quotes — e.g., `Revert "Generated SDK versions: v20111101"` would break inline `${{ }}` interpolation)
370392
- Parses HEAD commit message
371393
- Sets output: `skip_publish` = true/false
372394
- Used by subsequent jobs to determine execution
@@ -454,6 +476,22 @@ If v20250224 jobs depended directly on v20111101's publish job, the workflow wou
454476

455477
---
456478

479+
## Slack Failure Notifications
480+
481+
All workflows send Slack notifications on failure to the channel configured via `SLACK_WEBHOOK_URL`. Notifications include a clickable link to the specific failed workflow run URL for quick diagnosis.
482+
483+
| Workflow | Notification Scope |
484+
|----------|--------------------|
485+
| `openapi-generate-and-push.yml` | Generate job failures, Process-and-Push job failures |
486+
| `on-push-master.yml` | Orchestration job failures (check-skip-publish, detect-changes, delay). Publish/release jobs have their own notifications via `publish.yml` and `release.yml`. |
487+
| `generate.yml` | Generation failures |
488+
| `publish.yml` | Publish failures |
489+
| `release.yml` | Release failures |
490+
491+
**Message format**: The workflow name in Slack messages links directly to the failed run URL, making it easy to jump straight to the failing step without navigating through the GitHub Actions UI.
492+
493+
---
494+
457495
## Supporting Scripts
458496

459497
### version.rb - Multi-Version Support
@@ -643,8 +681,12 @@ on:
643681
# - 'openapi/**' (config changes alone)
644682
# - 'docs/**' (documentation changes)
645683
# - 'README.md' (root documentation)
684+
repository_dispatch:
685+
types: [automated_push_to_master] # Triggered by openapi-generate-and-push.yml
646686
```
647687

688+
The `repository_dispatch` trigger is required because automated pushes from `openapi-generate-and-push.yml` use `GITHUB_TOKEN`, which does not trigger `push` events for other workflows (GitHub security feature). The generate workflow sends this dispatch explicitly using a GitHub App token.
689+
648690
**Benefits**:
649691
- Enhancement PRs (docs only) don't trigger publish
650692
- Workflow file changes don't trigger publish
@@ -680,6 +722,8 @@ The repository uses **semantic versioning with major version = API version**:
680722
| `NPM_AUTH_TOKEN` | publish.yml | Authenticate to npm registry for publishing |
681723
| `GITHUB_TOKEN` | All workflows | GitHub API access (auto-provided by GitHub Actions) |
682724
| `SLACK_WEBHOOK_URL` | All workflows | Send failure notifications to Slack |
725+
| `APP_ID` | openapi-generate-and-push.yml | GitHub App ID for generating tokens that can trigger cross-workflow events |
726+
| `APP_PRIVATE_KEY` | openapi-generate-and-push.yml | GitHub App private key (used with `tibdex/github-app-token@v1` to create tokens for `repository_dispatch`) |
683727

684728
### Environment Setup
685729

@@ -706,13 +750,15 @@ openapi-generate-and-push.yml: Triggered
706750
├─ Download artifacts
707751
├─ Update CHANGELOG.md
708752
├─ Commit to master
709-
├─ Push to master (triggers on-push-master.yml)
753+
├─ Push to master
754+
├─ Send repository_dispatch (automated_push_to_master)
710755
711-
on-push-master.yml: Triggered (push event)
756+
on-push-master.yml: Triggered (repository_dispatch)
712757
├─ check-skip-publish: Verify no [skip-publish] flag
758+
├─ detect-changes: paths-filter with base: HEAD~1
713759
├─ publish-v20111101: npm publish (path filter matched)
714760
├─ release-v20111101: Create tag v2.0.1 (after publish)
715-
├─ publish-v20250224: npm publish (serialized, after v20111101 release)
761+
├─ publish-v20250224: npm publish (serialized, after delay)
716762
├─ release-v20250224: Create tag v3.0.1 (after publish)
717763
718764
Result: Both versions published and released sequentially, CHANGELOG updated

0 commit comments

Comments
 (0)