-
Notifications
You must be signed in to change notification settings - Fork 2
ci: notify the Postman collection pipeline when a spec release lands #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cb-logesh
wants to merge
1
commit into
main
Choose a base branch
from
cb-logesh/notify-postman-on-spec-release
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Tells the Postman collection pipeline that a specification release has landed. | ||
| # | ||
| # The specs in spec/ are updated by cb-sdk-gen's public-sdk-release, which opens | ||
| # a pull request here. Merging that pull request is the moment the specification | ||
| # becomes public — this repository's main branch is what downstream consumers | ||
| # read — so it is the moment worth announcing. | ||
| # | ||
| # The consumer, chargebee/cb-openapi-generator, regenerates its published Postman | ||
| # collections from spec/ and opens a pull request carrying the diff. Nothing | ||
| # auto-merges there; a human reads the semantic change. | ||
| # | ||
| # This is a latency optimisation, not a dependency. That pipeline also polls | ||
| # hourly and keys on this repository's commit SHA, so if the dispatch fails, is | ||
| # never configured, or this workflow is deleted, the collections still follow — | ||
| # just up to an hour later. Deliberately fails soft for the same reason: a | ||
| # specification release must not be reported as broken because a downstream | ||
| # notification could not be sent. | ||
| name: notify-postman | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'spec/**' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| notify: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Dispatch to cb-openapi-generator | ||
| env: | ||
| # Fine-grained token with Contents: read and write on | ||
| # chargebee/cb-openapi-generator — the permission repository_dispatch | ||
| # requires. Nothing else. | ||
| TOKEN: ${{ secrets.POSTMAN_REGEN_DISPATCH_TOKEN }} | ||
| SHA: ${{ github.sha }} | ||
| run: | | ||
| if [ -z "$TOKEN" ]; then | ||
| echo "::notice::POSTMAN_REGEN_DISPATCH_TOKEN is not set; skipping. The Postman pipeline polls hourly and will pick this up regardless." | ||
| exit 0 | ||
| fi | ||
|
|
||
| status=$(curl -sS -o /tmp/dispatch.out -w '%{http_code}' \ | ||
| -X POST "https://api.github.com/repos/chargebee/cb-openapi-generator/dispatches" \ | ||
| -H "Authorization: Bearer $TOKEN" \ | ||
| -H "Accept: application/vnd.github+json" \ | ||
| -H "X-GitHub-Api-Version: 2022-11-28" \ | ||
| -d "{\"event_type\":\"openapi-spec-published\",\"client_payload\":{\"sha\":\"$SHA\"}}") | ||
|
|
||
| if [ "$status" = "204" ]; then | ||
| echo "Notified cb-openapi-generator of ${SHA}." | ||
| else | ||
| # Soft failure on purpose: see the note at the top of this file. | ||
| echo "::warning::Dispatch returned HTTP ${status}. The Postman pipeline polls hourly, so this delays regeneration rather than preventing it." | ||
| cat /tmp/dispatch.out | ||
| fi | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When GitHub's API cannot be reached because of a DNS, connection, or TLS error,
curlexits nonzero (curl --manualdocuments failures such as exit 6 for DNS and 7 for connection errors). GitHub Actions runs this implicit Bash step with-e, and the assignment inheritscurl's exit status, so execution stops here instead of reaching the warning branch. This makes the workflow fail precisely for a class of downstream notification failures that the workflow says must fail soft; capture/neutralize the curl exit status before inspecting the result.Useful? React with 👍 / 👎.