1- name : Automated API tests using Postman (via Newman)
1+ name : Automated API tests using Postman
22
33on :
44 push :
5- branches :
6- - main
7- - develop
8- - feature/postman
5+ branches : [main, develop, feature/postman]
96 pull_request :
10- branches :
11- - main
12- - develop
7+ branches : [main, develop]
138 workflow_dispatch :
149
1510jobs :
1611 automated-api-tests :
1712 runs-on : ubuntu-latest
13+ env :
14+ POSTMAN_API_KEY : ${{ secrets.POSTMAN_API_KEY }}
15+ # 👇 REPLACE THIS WITH YOUR ACTUAL COLLECTION UID
16+ POSTMAN_COLLECTION_UID : " YOUR_COLLECTION_UID_HERE"
1817 steps :
1918 - uses : actions/checkout@v4
2019
@@ -23,32 +22,35 @@ jobs:
2322 with :
2423 node-version : ' 20'
2524
26- - name : Install Newman
25+ - name : Install Newman (official Postman runner)
2726 run : npm install -g newman
2827
29- - name : Download Postman Collection (via API or direct link)
30- env :
31- POSTMAN_API_KEY : ${{ secrets.POSTMAN_API_KEY }}
28+ - name : Download Postman Collection via API
3229 run : |
3330 mkdir -p collections
34- # Replace COLLECTION_UID with your actual Postman Collection UID
35- # Find it in Postman: Collection > ... > Share > Copy UID
36- COLLECTION_UID="YOUR_COLLECTION_UID_HERE"
37-
38- curl -s "https://api.getpostman.com/collections/$COLLECTION_UID" \
31+ echo "⬇️ Fetching collection UID: $POSTMAN_COLLECTION_UID"
32+ curl -sS \
3933 -H "X-API-Key: $POSTMAN_API_KEY" \
34+ "https://api.getpostman.com/collections/$POSTMAN_COLLECTION_UID" \
4035 -o collections/feedlink.json
4136
42- if [ ! -f collections/feedlink.json ] || grep -q "error" collections/feedlink.json; then
43- echo "❌ Failed to fetch collection. Check UID and API key."
44- cat collections/feedlink.json || echo "No response received."
37+ # Check if response contains an error
38+ if grep -q '"error"' collections/feedlink.json; then
39+ echo "❌ Failed to fetch collection. Response:"
40+ cat collections/feedlink.json
4541 exit 1
4642 fi
4743
48- echo "✅ Collection successfully downloaded: collections/feedlink.json"
44+ # Ensure file exists and has content
45+ if [ ! -s collections/feedlink.json ]; then
46+ echo "❌ Downloaded collection is empty."
47+ exit 1
48+ fi
49+
50+ echo "✅ Collection downloaded successfully."
4951 echo "📄 Size: $(wc -c < collections/feedlink.json) bytes"
5052
51- - name : Run API tests with Newman
53+ - name : Run API tests
5254 run : |
5355 mkdir -p reports
5456 newman run collections/feedlink.json \
0 commit comments