automated_push_to_master #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: On Push to Master | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'v20111101/**' | |
| - 'v20250224/**' | |
| repository_dispatch: | |
| types: [automated_push_to_master] | |
| jobs: | |
| # Check for skip-publish flag in commit message. This allows skipping publish/release for specific scenarios, | |
| # such as testing generated code, migrating files to new paths, etc. | |
| check-skip-publish: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| skip_publish: ${{ steps.check.outputs.skip_publish }} | |
| steps: | |
| - name: Check for [skip-publish] flag in commit message | |
| id: check | |
| env: | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| if [[ "$COMMIT_MSG" == *"[skip-publish]"* ]]; then | |
| echo "skip_publish=true" >> $GITHUB_OUTPUT | |
| echo "🚫 [skip-publish] flag detected - skipping all publish/release jobs" | |
| else | |
| echo "skip_publish=false" >> $GITHUB_OUTPUT | |
| echo "✅ No skip flag - proceeding with publish/release" | |
| fi | |
| # Detect which API versions were modified. | |
| # Two strategies based on event type: | |
| # - repository_dispatch: Read versions directly from the dispatch payload (api_versions). | |
| # This is reliable because openapi-generate-and-push.yml knows exactly which versions | |
| # it generated and passes them through. Using dorny/paths-filter for dispatch events | |
| # is unreliable (no before/after SHAs, falls back to "last commit" mode which can | |
| # misdetect changes depending on git history and shallow clone depth). | |
| # - push: Use dorny/paths-filter which works correctly with push event before/after SHAs. | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| v20111101: ${{ steps.dispatch-changes.outputs.v20111101 || steps.filter.outputs.v20111101 }} | |
| v20250224: ${{ steps.dispatch-changes.outputs.v20250224 || steps.filter.outputs.v20250224 }} | |
| steps: | |
| # For repository_dispatch: trust the payload from openapi-generate-and-push | |
| - name: Parse dispatch payload | |
| id: dispatch-changes | |
| if: github.event_name == 'repository_dispatch' | |
| run: | | |
| API_VERSIONS="${{ github.event.client_payload.api_versions }}" | |
| echo "Dispatch payload api_versions: $API_VERSIONS" | |
| # Default all versions to false | |
| echo "v20111101=false" >> $GITHUB_OUTPUT | |
| echo "v20250224=false" >> $GITHUB_OUTPUT | |
| # Set true for each version in the payload | |
| for VERSION in $(echo "$API_VERSIONS" | tr ',' ' '); do | |
| echo "${VERSION}=true" >> $GITHUB_OUTPUT | |
| echo " Detected version: $VERSION" | |
| done | |
| # For push events: use dorny/paths-filter (works correctly with push before/after SHAs) | |
| - uses: actions/checkout@v3 | |
| if: github.event_name == 'push' | |
| - uses: dorny/paths-filter@v2 | |
| if: github.event_name == 'push' | |
| id: filter | |
| with: | |
| filters: | | |
| v20111101: | |
| - 'v20111101/**' | |
| v20250224: | |
| - 'v20250224/**' | |
| # Publish and release for each version conditionally | |
| # Only runs if [skip-publish] flag is NOT present AND files for that version were modified | |
| publish-v20111101: | |
| needs: [check-skip-publish, detect-changes] | |
| if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.v20111101 == 'true' | |
| uses: ./.github/workflows/publish.yml | |
| with: | |
| version_directory: v20111101 | |
| secrets: inherit | |
| release-v20111101: | |
| needs: [check-skip-publish, detect-changes, publish-v20111101] | |
| if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.v20111101 == 'true' | |
| uses: ./.github/workflows/release.yml | |
| with: | |
| version_directory: v20111101 | |
| secrets: inherit | |
| delay-for-v20250224: | |
| runs-on: ubuntu-latest | |
| needs: [check-skip-publish, detect-changes] | |
| if: needs.check-skip-publish.outputs.skip_publish == 'false' | |
| steps: | |
| - name: Brief delay to stagger v20250224 publish | |
| run: sleep 2 | |
| publish-v20250224: | |
| needs: [check-skip-publish, detect-changes, delay-for-v20250224] | |
| if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.v20250224 == 'true' | |
| uses: ./.github/workflows/publish.yml | |
| with: | |
| version_directory: v20250224 | |
| secrets: inherit | |
| release-v20250224: | |
| needs: [check-skip-publish, detect-changes, publish-v20250224] | |
| if: needs.check-skip-publish.outputs.skip_publish == 'false' && needs.detect-changes.outputs.v20250224 == 'true' | |
| uses: ./.github/workflows/release.yml | |
| with: | |
| version_directory: v20250224 | |
| secrets: inherit | |
| # Notify on failure of orchestration jobs (check-skip-publish, detect-changes, delay). | |
| # Publish and release workflows have their own Slack notifications, so we only | |
| # monitor the jobs owned by this workflow to avoid double-alerting. | |
| slack-notification: | |
| runs-on: ubuntu-latest | |
| needs: [check-skip-publish, detect-changes, delay-for-v20250224] | |
| if: always() && (needs.check-skip-publish.result == 'failure' || needs.detect-changes.result == 'failure' || needs.delay-for-v20250224.result == 'failure') | |
| steps: | |
| - name: Slack notification | |
| uses: ravsamhq/notify-slack-action@v2 | |
| with: | |
| status: failure | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| notification_title: "{repo}: {workflow} workflow" | |
| message_format: "{emoji} *<{workflow_url}|{workflow}>* {status_message} in <{repo_url}|{repo}>" | |
| notify_when: "failure" | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |