1- name : Automated API tests using Postman
2-
1+ name : Automated API tests using Postman CLI
32on :
43 push :
5- branches : [main, develop, feature/postman]
4+ branches :
5+ - main
6+ - develop
7+ - feature/postman
68 pull_request :
7- branches : [main, develop]
9+ branches :
10+ - main
11+ - develop
812 workflow_dispatch :
9-
1013jobs :
1114 automated-api-tests :
1215 runs-on : ubuntu-latest
1316 env :
1417 POSTMAN_API_KEY : ${{ secrets.POSTMAN_API_KEY }}
15- POSTMAN_COLLECTION_UID : " 45722982-8ff3307d-6cc8-4a93-8194-c8843b990b99" # ✅ Your real UID
1618 steps :
1719 - uses : actions/checkout@v4
18-
19- - name : Set up Node.js
20- uses : actions/setup-node@v4
21- with :
22- node-version : ' 20'
23-
24- - name : Install Newman (official Postman runner)
25- run : npm install -g newman
26-
27- - name : Download Postman Collection via API
20+ - name : Install Postman CLI
2821 run : |
29- mkdir -p collections
30- echo "⬇️ Fetching collection UID: $POSTMAN_COLLECTION_UID"
31- curl -sS \
32- -H "X-API-Key: $POSTMAN_API_KEY" \
33- "https://api.getpostman.com/collections/$POSTMAN_COLLECTION_UID" \
34- -o collections/feedlink.json
35-
36- # Check if response contains an error
37- if grep -q '"error"' collections/feedlink.json; then
38- echo "❌ Failed to fetch collection. Response:"
39- cat collections/feedlink.json
40- exit 1
41- fi
42-
43- # Ensure file exists and has content
44- if [ ! -s collections/feedlink.json ]; then
45- echo "❌ Downloaded collection is empty."
46- exit 1
47- fi
48-
49- echo "✅ Collection downloaded successfully."
50- echo "📄 Size: $(wc -c < collections/feedlink.json) bytes"
51-
22+ curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
23+ - name : Login to Postman CLI
24+ run : postman login --with-api-key "$POSTMAN_API_KEY"
5225 - name : Run API tests
5326 run : |
5427 mkdir -p reports
55- newman run collections/feedlink.json \
28+ postman pull \
29+ postman collection run "Feedlink" \
5630 --reporters cli,junit \
5731 --reporter-junit-export reports/junit.xml
58-
5932 - name : Upload JUnit report
6033 uses : actions/upload-artifact@v4
6134 with :
6235 name : postman-junit
63- path : reports/junit.xml
36+ path : reports/junit.xml
37+
38+
39+
40+
41+
0 commit comments