Skip to content

Commit 637bd56

Browse files
GvieveGenevieve Nuebel
andauthored
Apply Validated Workflow Fixes from Sandbox Testing (#92)
* Update workflows with final fixes * And some more fixes * Update docs --------- Co-authored-by: Genevieve Nuebel <genevieve.nuebel@mx.com>
1 parent b875174 commit 637bd56

File tree

9 files changed

+234
-57
lines changed

9 files changed

+234
-57
lines changed

.github/workflows/generate.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ jobs:
9393
git config user.name "devexperience"
9494
git config user.email "devexperience@mx.com"
9595
git add .
96-
git commit -m "Generated API ${{ github.event.inputs.api_version }} SDK for version ${{ steps.bump_version.outputs.version }}
96+
git commit -m "Manually Generated API ${{ github.event.inputs.api_version }} SDK for version ${{ steps.bump_version.outputs.version }}
9797
98-
This pull request was automatically generated by a GitHub Action.
98+
This pull request was automatically generated by generate GitHub Action.
9999
100100
API Version: ${{ github.event.inputs.api_version }}
101101
SDK Version: ${{ steps.bump_version.outputs.version }}
@@ -113,8 +113,7 @@ jobs:
113113
status: ${{ job.status }}
114114
token: ${{ secrets.GITHUB_TOKEN }}
115115
notification_title: "{repo}: {workflow} workflow"
116-
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
117-
footer: "<{workflow_url}|View Workflow>"
116+
message_format: "{emoji} *<{workflow_url}|{workflow}>* {status_message} in <{repo_url}|{repo}>"
118117
notify_when: "failure"
119118
env:
120119
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
paths:
77
- 'v20111101/**'
88
- 'v20250224/**'
9+
repository_dispatch:
10+
types: [automated_push_to_master]
911

1012
jobs:
1113
# Check for skip-publish flag in commit message. This allows skipping publish/release for specific scenarios,
@@ -17,8 +19,9 @@ jobs:
1719
steps:
1820
- name: Check for [skip-publish] flag in commit message
1921
id: check
22+
env:
23+
COMMIT_MSG: ${{ github.event.head_commit.message }}
2024
run: |
21-
COMMIT_MSG="${{ github.event.head_commit.message }}"
2225
if [[ "$COMMIT_MSG" == *"[skip-publish]"* ]]; then
2326
echo "skip_publish=true" >> $GITHUB_OUTPUT
2427
echo "🚫 [skip-publish] flag detected - skipping all publish/release jobs"
@@ -27,9 +30,11 @@ jobs:
2730
echo "✅ No skip flag - proceeding with publish/release"
2831
fi
2932
30-
# Detect which API versions were modified in this push
31-
# Uses dorny/paths-filter to reliably check which directories changed
32-
# This allows us to run publish/release jobs only for versions that were actually modified
33+
# Detect which API versions were modified
34+
# Uses dorny/paths-filter to check which version directories changed.
35+
# For push events: paths-filter uses github.event.before/after automatically.
36+
# For repository_dispatch events: both push and dispatch target master (same branch),
37+
# so we compare HEAD against HEAD~1 to detect changes from the just-pushed commit.
3338
detect-changes:
3439
runs-on: ubuntu-latest
3540
outputs:
@@ -40,6 +45,7 @@ jobs:
4045
- uses: dorny/paths-filter@v2
4146
id: filter
4247
with:
48+
base: ${{ github.event_name == 'repository_dispatch' && 'HEAD~1' || '' }}
4349
filters: |
4450
v20111101:
4551
- 'v20111101/**'
@@ -88,3 +94,22 @@ jobs:
8894
with:
8995
version_directory: v20250224
9096
secrets: inherit
97+
98+
# Notify on failure of orchestration jobs (check-skip-publish, detect-changes, delay).
99+
# Publish and release workflows have their own Slack notifications, so we only
100+
# monitor the jobs owned by this workflow to avoid double-alerting.
101+
slack-notification:
102+
runs-on: ubuntu-latest
103+
needs: [check-skip-publish, detect-changes, delay-for-v20250224]
104+
if: always() && (needs.check-skip-publish.result == 'failure' || needs.detect-changes.result == 'failure' || needs.delay-for-v20250224.result == 'failure')
105+
steps:
106+
- name: Slack notification
107+
uses: ravsamhq/notify-slack-action@v2
108+
with:
109+
status: failure
110+
token: ${{ secrets.GITHUB_TOKEN }}
111+
notification_title: "{repo}: {workflow} workflow"
112+
message_format: "{emoji} *<{workflow_url}|{workflow}>* {status_message} in <{repo_url}|{repo}>"
113+
notify_when: "failure"
114+
env:
115+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

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

Lines changed: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ name: "OpenAPI: Automated Generate and Push"
33
on:
44
repository_dispatch:
55
types: [generate_publish_release]
6-
workflow_dispatch:
7-
inputs:
8-
payload_json:
9-
description: 'JSON payload (e.g., {"api_versions":"v20111101","version":"patch","commit_sha":"abc123"})'
10-
required: false
11-
type: string
126

137
jobs:
148
Setup:
@@ -20,12 +14,7 @@ jobs:
2014
- name: Parse payload
2115
id: parse-payload
2216
run: |
23-
# Parse workflow_dispatch payload if provided, otherwise use repository_dispatch payload
24-
if [ -n "${{ github.event.inputs.payload_json }}" ]; then
25-
VERSIONS=$(echo '${{ github.event.inputs.payload_json }}' | jq -r '.api_versions // "v20111101"')
26-
else
27-
VERSIONS="${{ github.event.client_payload.api_versions || 'v20111101' }}"
28-
fi
17+
VERSIONS="${{ github.event.client_payload.api_versions || 'v20111101' }}"
2918
echo "versions_to_generate=$VERSIONS" >> $GITHUB_OUTPUT
3019
3120
- name: Set up matrix
@@ -74,33 +63,28 @@ jobs:
7463
ruby-version: 3.1
7564
- name: Validate configuration
7665
run: ruby .github/config_validator.rb "${{ matrix.config_file }}" "${{ matrix.api_version }}"
66+
7767
- name: Bump version
7868
id: bump_version
7969
run: |
80-
# Parse version from workflow_dispatch or repository_dispatch
81-
if [ -n "${{ github.event.inputs.payload_json }}" ]; then
82-
VERSION=$(echo '${{ github.event.inputs.payload_json }}' | jq -r '.version // "patch"')
83-
else
84-
VERSION="${{ github.event.client_payload.version || 'patch' }}"
85-
fi
86-
NEW_VERSION=$(ruby .github/version.rb "$VERSION" ${{ matrix.config_file }})
70+
VERSION="${{ github.event.client_payload.version || 'patch' }}"
71+
NEW_VERSION=$(ruby .github/version.rb $VERSION ${{ matrix.config_file }})
8772
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
73+
8874
- name: Clean repo
8975
run: ruby .github/clean.rb ${{ matrix.api_version }}
76+
9077
- name: Copy generator ignore rules
9178
run: |
9279
mkdir -p ./${{ matrix.api_version }}/
9380
cp .openapi-generator-ignore ./${{ matrix.api_version }}/
81+
9482
- name: Install openapi-generator-cli
9583
run: npm install @openapitools/openapi-generator-cli -g
84+
9685
- name: Generate SDK
9786
run: |
98-
# Parse commit_sha from workflow_dispatch or repository_dispatch
99-
if [ -n "${{ github.event.inputs.payload_json }}" ]; then
100-
COMMIT_SHA=$(echo '${{ github.event.inputs.payload_json }}' | jq -r '.commit_sha // "master"')
101-
else
102-
COMMIT_SHA="${{ github.event.client_payload.commit_sha || 'master' }}"
103-
fi
87+
COMMIT_SHA="${{ github.event.client_payload.commit_sha || 'master' }}"
10488
10589
# Versioned spec URLs with commit SHA to avoid GitHub CDN cache race condition
10690
# Problem: GitHub's raw.githubusercontent.com CDN caches files for 5 minutes
@@ -113,11 +97,18 @@ jobs:
11397
-c ${{ matrix.config_file }} \
11498
-t ./openapi/templates \
11599
-o ./${{ matrix.api_version }}
116-
- name: Upload artifacts
100+
101+
- name: Upload SDK artifacts
117102
uses: actions/upload-artifact@v4
118103
with:
119104
name: generated-${{ matrix.api_version }}
120105
path: ./${{ matrix.api_version }}
106+
107+
- name: Upload config artifact
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: config-${{ matrix.api_version }}
111+
path: ${{ matrix.config_file }}
121112

122113
Process-and-Push:
123114
runs-on: ubuntu-latest
@@ -128,18 +119,41 @@ jobs:
128119
uses: actions/download-artifact@v4
129120
with:
130121
path: ./generated
122+
123+
- name: Restore config files from artifacts
124+
run: |
125+
# Config files are bumped in the Generate job (separate runner).
126+
# Restore them here so the version bump persists in the commit.
127+
for dir in ./generated/config-*; do
128+
[ -d "$dir" ] || continue
129+
VERSION=$(basename "$dir" | sed 's/config-//')
130+
CONFIG_FILE="openapi/config-${VERSION}.yml"
131+
cp "$dir"/* "./$CONFIG_FILE" 2>/dev/null || echo "Config not found in $dir"
132+
echo "Restored $CONFIG_FILE"
133+
done
134+
135+
# Clean up config artifact directories so they don't get committed
136+
rm -rf ./generated/config-*
137+
131138
- name: Move generated files and track versions
132139
id: track_versions
133140
run: |
134141
GENERATED_VERSIONS=""
135142
136143
for dir in ./generated/generated-*; do
137144
VERSION=$(basename "$dir" | sed 's/generated-//')
145+
146+
# Remove target directory before moving to prevent nesting
147+
if [ -d "./$VERSION" ]; then
148+
rm -rf "./$VERSION"
149+
fi
150+
138151
mv "$dir" "./$VERSION"
139152
GENERATED_VERSIONS="$GENERATED_VERSIONS $VERSION"
140153
done
141154
142155
echo "generated_versions=$GENERATED_VERSIONS" >> $GITHUB_OUTPUT
156+
143157
- name: Update CHANGELOG
144158
run: |
145159
GENERATED_VERSIONS="${{ steps.track_versions.outputs.generated_versions }}"
@@ -154,6 +168,7 @@ jobs:
154168
# Trim leading/trailing whitespace first
155169
VERSIONS_CSV=$(echo "$GENERATED_VERSIONS" | xargs | tr ' ' ',')
156170
ruby .github/changelog_manager.rb "$VERSIONS_CSV"
171+
157172
- name: Copy documentation
158173
run: |
159174
GENERATED_VERSIONS="${{ steps.track_versions.outputs.generated_versions }}"
@@ -163,17 +178,46 @@ jobs:
163178
cp CHANGELOG.md "./$VERSION/CHANGELOG.md"
164179
cp MIGRATION.md "./$VERSION/MIGRATION.md"
165180
done
181+
166182
- name: Checkout master
167183
run: git checkout master
168184
- name: Create commit
169185
run: |
170186
git config user.name "devexperience"
171187
git config user.email "devexperience@mx.com"
172188
git add .
173-
git commit -m "Generated SDK versions: ${{ needs.Setup.outputs.versions_to_generate }}
189+
git commit -m "Automated Generated SDK versions: ${{ needs.Setup.outputs.versions_to_generate }}
174190
175-
This commit was automatically created by a GitHub Action."
191+
This commit was automatically created by openapi-generate-and-push GitHub Action."
176192
- name: Push to master
177193
run: git push origin master
178194
env:
179195
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
196+
197+
# GitHub security feature: pushes using GITHUB_TOKEN don't trigger other workflows.
198+
# We must explicitly trigger on-push-master.yml using a GitHub App token.
199+
- name: Generate access token
200+
id: generate_token
201+
uses: tibdex/github-app-token@v1
202+
with:
203+
app_id: ${{ secrets.PAPI_SDK_APP_ID }}
204+
installation_id: ${{ secrets.PAPI_SDK_INSTALLATION_ID }}
205+
private_key: ${{ secrets.PAPI_SDK_PRIVATE_KEY }}
206+
207+
- name: Trigger publish and release workflow
208+
uses: peter-evans/repository-dispatch@v2
209+
with:
210+
token: ${{ steps.generate_token.outputs.token }}
211+
event-type: automated_push_to_master
212+
213+
- name: Slack notification
214+
uses: ravsamhq/notify-slack-action@v2
215+
if: always()
216+
with:
217+
status: ${{ job.status }}
218+
token: ${{ secrets.GITHUB_TOKEN }}
219+
notification_title: "{repo}: {workflow} workflow"
220+
message_format: "{emoji} *<{workflow_url}|{workflow}>* {status_message} in <{repo_url}|{repo}>"
221+
notify_when: "failure"
222+
env:
223+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/publish.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ jobs:
4040
status: ${{ job.status }}
4141
token: ${{ secrets.GITHUB_TOKEN }}
4242
notification_title: "{repo}: {workflow} workflow"
43-
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
44-
footer: "<{workflow_url}|View Workflow>"
43+
message_format: "{emoji} *<{workflow_url}|{workflow}>* {status_message} in <{repo_url}|{repo}>"
4544
notify_when: "failure"
4645
env:
4746
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ jobs:
4242
status: ${{ job.status }}
4343
token: ${{ secrets.GITHUB_TOKEN }}
4444
notification_title: "{repo}: {workflow} workflow"
45-
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
46-
footer: "<{workflow_url}|View Workflow>"
45+
message_format: "{emoji} *<{workflow_url}|{workflow}>* {status_message} in <{repo_url}|{repo}>"
4746
notify_when: "failure"
4847
env:
4948
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

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

0 commit comments

Comments
 (0)