-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (54 loc) · 1.59 KB
/
main.yaml
File metadata and controls
62 lines (54 loc) · 1.59 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
56
57
58
59
60
61
62
name: Build Test and push
on: [push]
env:
IMAGE_NAME: student_service
REPO_NAME: noahvanos
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build docker
run: |
docker build . -t $REPO_NAME/$IMAGE_NAME
- name: run docker
run: |
docker run -d -p 8080:8080 $REPO_NAME/$IMAGE_NAME:latest && \
docker ps && sleep 5
- name: "Check files existence"
uses: andstor/file-existence-action@v2
with:
files: "postman/collection.json,postman/environment.json"
fail: true
- name: Run API Tests
id: run-newman
uses: anthonyvscode/newman-action@master
with:
collection: postman/collection.json
environment: postman/environment.json
reporters: cli
bail: true
- name: Check if we failed
id: fail-check
shell: bash
env:
JSON_DOC: ${{ steps.run-newman.outputs.summary }}
run: |
printf '%s\n' "$JSON_DOC" > summary.json
cat summary.json
if grep -q Collection summary.json; then
echo "failed=false" >> $GITHUB_OUTPUT;
else
echo "failed=true" >> $GITHUB_OUTPUT;
fi
- name: fail if empty
if: ${{ steps.fail-check.outputs.failed == 'true' }}
run: exit 1
- name: Login to Container Registry
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Push image to docker hub Container Registry
run: |
docker push $REPO_NAME/$IMAGE_NAME