Skip to content

Commit 35e68c6

Browse files
GvieveGenevieve Nuebel
andauthored
fix: pass api_versions in dispatch payload (#95)
Co-authored-by: Genevieve Nuebel <genevieve.nuebel@mx.com>
1 parent 7888f97 commit 35e68c6

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,45 @@ jobs:
3030
echo "✅ No skip flag - proceeding with publish/release"
3131
fi
3232
33-
# Detect which API versions were modified
34-
# Uses dorny/paths-filter to check which version directories changed.
35-
# For push events: default base (empty) uses github.event.before/after automatically.
36-
# For repository_dispatch events: setting base to 'master' (same branch) triggers
37-
# paths-filter's "last commit" comparison mode per the docs.
33+
# Detect which API versions were modified.
34+
# Two strategies based on event type:
35+
# - repository_dispatch: Read versions directly from the dispatch payload (api_versions).
36+
# This is reliable because openapi-generate-and-push.yml knows exactly which versions
37+
# it generated and passes them through. Using dorny/paths-filter for dispatch events
38+
# is unreliable (no before/after SHAs, falls back to "last commit" mode which can
39+
# misdetect changes depending on git history and shallow clone depth).
40+
# - push: Use dorny/paths-filter which works correctly with push event before/after SHAs.
3841
detect-changes:
3942
runs-on: ubuntu-latest
4043
outputs:
41-
v20111101: ${{ steps.filter.outputs.v20111101 }}
42-
v20250224: ${{ steps.filter.outputs.v20250224 }}
44+
v20111101: ${{ steps.dispatch-changes.outputs.v20111101 || steps.filter.outputs.v20111101 }}
45+
v20250224: ${{ steps.dispatch-changes.outputs.v20250224 || steps.filter.outputs.v20250224 }}
4346
steps:
47+
# For repository_dispatch: trust the payload from openapi-generate-and-push
48+
- name: Parse dispatch payload
49+
id: dispatch-changes
50+
if: github.event_name == 'repository_dispatch'
51+
run: |
52+
API_VERSIONS="${{ github.event.client_payload.api_versions }}"
53+
echo "Dispatch payload api_versions: $API_VERSIONS"
54+
55+
# Default all versions to false
56+
echo "v20111101=false" >> $GITHUB_OUTPUT
57+
echo "v20250224=false" >> $GITHUB_OUTPUT
58+
59+
# Set true for each version in the payload
60+
for VERSION in $(echo "$API_VERSIONS" | tr ',' ' '); do
61+
echo "${VERSION}=true" >> $GITHUB_OUTPUT
62+
echo " Detected version: $VERSION"
63+
done
64+
65+
# For push events: use dorny/paths-filter (works correctly with push before/after SHAs)
4466
- uses: actions/checkout@v3
67+
if: github.event_name == 'push'
4568
- uses: dorny/paths-filter@v2
69+
if: github.event_name == 'push'
4670
id: filter
4771
with:
48-
base: ${{ github.event_name == 'repository_dispatch' && 'master' || '' }}
4972
filters: |
5073
v20111101:
5174
- 'v20111101/**'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ jobs:
209209
with:
210210
token: ${{ steps.generate_token.outputs.token }}
211211
event-type: automated_push_to_master
212+
client-payload: '{"api_versions": "${{ needs.Setup.outputs.versions_to_generate }}"}'
212213

213214
- name: Slack notification
214215
uses: ravsamhq/notify-slack-action@v2

0 commit comments

Comments
 (0)