Merge pull request #140 from Terminal49/matt/data-6538-api-documentation #6
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: Deploy Postman Collection | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: # Add this to enable manual triggering | |
| jobs: | |
| deploy-postman-collection: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install jq (for Postman API call) | |
| run: sudo apt-get update && sudo apt-get install -y jq | |
| - name: Deploy to Postman API | |
| env: | |
| POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }} | |
| POSTMAN_COLLECTION_UID: 5900de09-f05a-4528-8b12-9ad1d0477023 | |
| run: | | |
| echo "On main branch with changes to collection - deploying to Postman API..." | |
| # Verify collection file exists (it should, but check anyway) | |
| if [ ! -f "Terminal49-API.postman_collection.json" ]; then | |
| echo "Error: Collection file not found!" | |
| exit 1 | |
| fi | |
| # Construct the JSON payload | |
| JSON_PAYLOAD=$(jq --null-input --rawfile collection "Terminal49-API.postman_collection.json" '{ "collection": ($collection | fromjson) }') | |
| # Check if jq succeeded | |
| if [ $? -ne 0 ]; then | |
| echo "Error: jq failed to process the collection file. Is it valid JSON?" | |
| exit 1 | |
| fi | |
| # Save the payload to a file instead of trying to pass it directly | |
| echo "$JSON_PAYLOAD" > postman_payload.json | |
| # Use the file with curl instead of passing the data directly | |
| curl --location --fail --request PUT "https://api.getpostman.com/collections/$POSTMAN_COLLECTION_UID" \ | |
| --header 'Content-Type: application/json' \ | |
| --header "X-Api-Key: $POSTMAN_API_KEY" \ | |
| --data @postman_payload.json | |
| if [ $? -eq 0 ]; then | |
| echo "✅ Postman collection update request sent successfully." | |
| else | |
| echo "❌ Error: Failed to update Postman collection via API." | |
| exit 1 | |
| fi |