1010 required : false
1111 type : string
1212
13- env :
14- # Parse payload from workflow_dispatch if provided, otherwise empty object
15- PARSED_PAYLOAD : ${{ fromJson(github.event.inputs.payload_json || '{}') }}
16- # Default to v20111101 only for backwards compatibility
17- # When openapi repo sends api_versions, use that instead
18- VERSIONS_TO_GENERATE : ${{ github.event.client_payload.api_versions || env.PARSED_PAYLOAD.api_versions || 'v20111101' }}
19-
2013jobs :
2114 Setup :
2215 runs-on : ubuntu-latest
2316 outputs :
2417 matrix : ${{ steps.set-matrix.outputs.matrix }}
18+ versions_to_generate : ${{ steps.parse-payload.outputs.versions_to_generate }}
2519 steps :
20+ - name : Parse payload
21+ id : parse-payload
22+ 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
29+ echo "versions_to_generate=$VERSIONS" >> $GITHUB_OUTPUT
30+
2631 - name : Set up matrix
2732 id : set-matrix
2833 run : |
29- VERSIONS="${{ env.VERSIONS_TO_GENERATE }}"
34+ VERSIONS="${{ steps.parse-payload.outputs.versions_to_generate }}"
3035 echo "Versions to generate: $VERSIONS"
3136
3237 # Build matrix JSON
7277 - name : Bump version
7378 id : bump_version
7479 run : |
75- NEW_VERSION=$(ruby .github/version.rb ${{ github.event.client_payload.version || env.PARSED_PAYLOAD.version || 'patch' }} ${{ matrix.config_file }})
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 }})
7687 echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
7788 - name : Clean repo
7889 run : ruby .github/clean.rb ${{ matrix.api_version }}
@@ -84,13 +95,20 @@ jobs:
8495 run : npm install @openapitools/openapi-generator-cli -g
8596 - name : Generate SDK
8697 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
104+
87105 # Versioned spec URLs with commit SHA to avoid GitHub CDN cache race condition
88106 # Problem: GitHub's raw.githubusercontent.com CDN caches files for 5 minutes
89107 # If openapi repo commits and immediately triggers this workflow, CDN may serve stale spec
90108 # Using commit SHA in URL to bypass cache and guarantee correct spec version
91109 # Falls back to 'master' if openapi doesn't send commit_sha
92110 openapi-generator-cli generate \
93- -i https://raw.githubusercontent.com/mxenabled/openapi/${{ github.event.client_payload.commit_sha || env.PARSED_PAYLOAD.commit_sha || 'master' }} /openapi/${{ matrix.api_version }}.yml \
111+ -i https://raw.githubusercontent.com/mxenabled/openapi/$COMMIT_SHA /openapi/${{ matrix.api_version }}.yml \
94112 -g typescript-axios \
95113 -c ${{ matrix.config_file }} \
96114 -t ./openapi/templates \
@@ -151,7 +169,7 @@ jobs:
151169 git config user.name "devexperience"
152170 git config user.email "devexperience@mx.com"
153171 git add .
154- git commit -m "Generated SDK versions: ${{ env.VERSIONS_TO_GENERATE }}
172+ git commit -m "Generated SDK versions: ${{ needs.Setup.outputs.versions_to_generate }}
155173
156174 This commit was automatically created by a GitHub Action."
157175 - name : Push to master
0 commit comments