Merge pull request #149 from AIRInstitute/pre #182
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 all | |
| on: | |
| push: | |
| branches: | |
| - 'prod' | |
| jobs: | |
| check_out: | |
| name: check out | |
| runs-on: [self-hosted, linux, x64, prod] | |
| steps: | |
| - uses: actions/checkout@v1 | |
| - name: Stop old containers except rtsp-stream and nginx-hls (if exist) | |
| run: sudo docker ps -a --format '{{.ID}} {{.Names}}' | awk '!/rtsp-stream|nginx-hls/ {print $1}' | xargs -r sudo docker stop | |
| continue-on-error: true | |
| - name: Remove old containers except rtsp-stream and nginx-hls (if exist) | |
| run: sudo docker ps -a --format '{{.ID}} {{.Names}}' | awk '!/rtsp-stream|nginx-hls/ {print $1}' | xargs -r sudo docker rm | |
| continue-on-error: true | |
| - name: Remove old images | |
| run: sudo docker rmi $(docker images -a -q) | |
| continue-on-error: true | |
| - name: Clear all Docker | |
| run: sudo docker system prune --all -f || true | |
| copy_file: | |
| name: copy file | |
| needs: check_out | |
| runs-on: [self-hosted, linux, x64, prod] | |
| steps: | |
| - name: copy file | |
| run: cp /etc/envs/.env . | |
| docker_compose: | |
| name: docker compose | |
| needs: copy_file | |
| runs-on: [self-hosted, linux, x64, prod] | |
| steps: | |
| - name: Build and run docker-compose | |
| run: docker compose -f docker-compose.yml --env-file /etc/envs/.env up -d --build --remove-orphans | |
| - name: List running containers | |
| run: sudo docker ps | |
| scan_with_trivy: | |
| name: scan with trivy | |
| needs: docker_compose | |
| runs-on: [self-hosted, linux, x64] | |
| steps: | |
| - name: Run Trivy vulnerability scanner in fs mode | |
| uses: anandg112/trivy-action@feat/add-skip-dirs-option | |
| with: | |
| image-ref: $(docker images -a -q) | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| ignore-unfixed: true | |
| format: 'table' | |
| skip-dirs: "ignored-dir" |