improve and tested endpoint average grade #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |