Update Postman Collection #2
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: Update Postman Collection | |
| on: | |
| push: | |
| paths: | |
| - spoonacular-openapi-3.json | |
| workflow_dispatch: | |
| jobs: | |
| publish-postman: | |
| name: Publish Postman Collection | |
| runs-on: ubuntu-latest | |
| env: | |
| POSTMAN_COLLECTION_ID: ${{ vars.POSTMAN_COLLECTION_ID }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install OpenAPI -> Postman converter | |
| run: npm i -g openapi-to-postmanv2 | |
| - name: Convert OpenAPI to Postman Collection | |
| run: | | |
| openapi2postmanv2 \ | |
| -s spoonacular-openapi-3.json \ | |
| -o postman-collection.json \ | |
| -p | |
| - name: Wrap collection JSON for Postman API | |
| run: | | |
| echo '{"collection":' > postman-collection-wrapped.json | |
| cat postman-collection.json >> postman-collection-wrapped.json | |
| echo '}' >> postman-collection-wrapped.json | |
| - name: Update Postman collection via API | |
| run: | | |
| curl -X PUT "https://api.getpostman.com/collections/${POSTMAN_COLLECTION_ID}" \ | |
| -H "X-Api-Key: ${{ secrets.POSTMAN_API_KEY }}" \ | |
| -H "Content-Type: application/json" \ | |
| --data-binary @postman-collection-wrapped.json |