-
Notifications
You must be signed in to change notification settings - Fork 5
55 lines (45 loc) · 2.08 KB
/
Copy pathdeploy_postman.yml
File metadata and controls
55 lines (45 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Deploy Postman Collection
on:
push:
branches:
- main
workflow_dispatch: # Add this to enable manual triggering
jobs:
deploy-postman-collection:
runs-on: ${{ (startsWith(vars.CI_RUNNER_SMALL, 'blacksmith-') && vars.CI_RUNNER_SMALL) || 'blacksmith-2vcpu-ubuntu-2404' }}
steps:
- name: Checkout repository
uses: useblacksmith/checkout@v1
- 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