Skip to content

Commit e93b975

Browse files
updated
1 parent 8f34d16 commit e93b975

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

.github/workflows/postman.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Automated API tests using Postman CLI
1+
name: Automated API tests using Postman (via Newman)
22

33
on:
44
push:
@@ -15,43 +15,43 @@ on:
1515
jobs:
1616
automated-api-tests:
1717
runs-on: ubuntu-latest
18-
env:
19-
POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}
2018
steps:
2119
- uses: actions/checkout@v4
2220

23-
- name: Install Postman CLI
24-
run: |
25-
# Fixed: removed trailing space in URL
26-
curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
2725

28-
- name: Login to Postman CLI
29-
run: postman login --with-api-key "$POSTMAN_API_KEY"
26+
- name: Install Newman
27+
run: npm install -g newman
3028

31-
- name: Pull and Verify Postman Collection
29+
- name: Download Postman Collection (via API or direct link)
30+
env:
31+
POSTMAN_API_KEY: ${{ secrets.POSTMAN_API_KEY }}
3232
run: |
3333
mkdir -p collections
34-
echo "⬇️ Attempting to pull collection: Feedlink"
35-
postman pull "Feedlink" --output collections/feedlink.json
36-
37-
# Verify the file exists and is not empty
38-
if [ ! -f collections/feedlink.json ] || [ ! -s collections/feedlink.json ]; then
39-
echo "❌ ERROR: Failed to pull collection 'Feedlink'."
40-
echo "📋 Available collections in your workspaces:"
41-
postman list collections
42-
echo ""
43-
echo "💡 Make sure the name matches EXACTLY (case, spaces, symbols)."
44-
echo "✅ Recommendation: Use the collection UID instead of name."
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" \
39+
-H "X-API-Key: $POSTMAN_API_KEY" \
40+
-o collections/feedlink.json
41+
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."
4545
exit 1
4646
fi
4747
48-
echo "✅ Collection successfully pulled: collections/feedlink.json"
48+
echo "✅ Collection successfully downloaded: collections/feedlink.json"
4949
echo "📄 Size: $(wc -c < collections/feedlink.json) bytes"
5050
51-
- name: Run API tests
51+
- name: Run API tests with Newman
5252
run: |
5353
mkdir -p reports
54-
postman collection run collections/feedlink.json \
54+
newman run collections/feedlink.json \
5555
--reporters cli,junit \
5656
--reporter-junit-export reports/junit.xml
5757

0 commit comments

Comments
 (0)