Skip to content

Commit

Permalink
feat: Added health check stage
Browse files Browse the repository at this point in the history
  • Loading branch information
ciro-mota committed Dec 14, 2023
1 parent 8010c2b commit 90be323
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build Docker Image
run: docker image build . --file Dockerfile --tag ciromota/nessus-scanner:latest
run: docker buildx build -t ciromota/nessus-scanner:latest .

Test:
needs: Build
Expand All @@ -31,7 +31,7 @@ jobs:
- uses: actions/checkout@v4

- name: Build Docker Image
run: docker image build . --file Dockerfile --tag ciromota/nessus-scanner:latest
run: docker buildx build -t ciromota/nessus-scanner:latest .

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
Expand All @@ -43,8 +43,18 @@ jobs:
vuln-type: 'os,library'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'

- name: Docker Container Run
run: docker container run -td --name nessus-scanner -p 8834:8834 -v /etc/localtime:/etc/localtime ciromota/nessus-scanner:latest
- name: Container Running and Health Check
run: |
docker container run -td --name nessus-scanner -p 8834:8834 -v /etc/localtime:/etc/localtime ciromota/nessus-scanner:latest
CONTAINER_NAME=$(docker ps -a | awk 'FNR==2{print $1}')
if docker inspect -f '{{.State.Running}}' "$CONTAINER_NAME" 2>/dev/null | grep -q "true"; then
echo "::notice:: All tests OK. :rocket:"
else
echo "::error:: Failing, reason: Container is not running."
exit 1
fi
Push:
needs: Test
Expand Down

0 comments on commit 90be323

Please sign in to comment.