File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Build Test and push
2+ on : [push]
3+ env :
4+ IMAGE_NAME : student_service
5+ REPO_NAME :
6+
7+
8+ jobs :
9+ build :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - uses : actions/checkout@v2
13+ - name : Build docker
14+ run : |
15+ docker build . -t $REPO_NAME/$IMAGE_NAME
16+ - name : run docker
17+ run : |
18+ docker run -d -p 8080:8080 $REPO_NAME/$IMAGE_NAME:latest && \
19+ docker ps && sleep 5
20+
21+ - name : " Check files existence"
22+ uses : andstor/file-existence-action@v2
23+ with :
24+ files : " postman/collection.json,postman/environment.json"
25+ fail : true
26+
27+ - name : Run API Tests
28+ id : run-newman
29+ uses : anthonyvscode/newman-action@master
30+ with :
31+ collection : postman/collection.json
32+ environment : postman/environment.json
33+ reporters : cli
34+ bail : true
35+
36+ - name : Check if we failed
37+ id : fail-check
38+ shell : bash
39+ env :
40+ JSON_DOC : ${{ steps.run-newman.outputs.summary }}
41+ run : |
42+ printf '%s\n' "$JSON_DOC" > summary.json
43+ cat summary.json
44+ if grep -q Collection summary.json; then
45+ echo "failed=false" >> $GITHUB_OUTPUT;
46+ else
47+ echo "failed=true" >> $GITHUB_OUTPUT;
48+ fi
49+
50+ - name : fail if empty
51+ if : ${{ steps.fail-check.outputs.failed == 'true' }}
52+ run : exit 1
53+
54+ - name : Login to Container Registry
55+ uses : docker/login-action@v1
56+ with :
57+ username : ${{ secrets.REGISTRY_USERNAME }}
58+ password : ${{ secrets.REGISTRY_PASSWORD }}
59+
60+ - name : Push image to docker hub Container Registry
61+ run : |
62+ docker push $REPO_NAME/$IMAGE_NAME
You can’t perform that action at this time.
0 commit comments