name change central-repo and added SAST, DAST, LINT and sonarcloud qu… #1
This file contains 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: ZAP Full Scan | |
on: | |
push: | |
branches: [main, feature/*] | |
pull_request: | |
branches: [main] | |
jobs: | |
zap_scan: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Build with Maven | |
run: mvn clean package | |
# Step 1: Create Docker network | |
- name: Create Docker Network | |
run: docker network create zap-network | |
# Step 2: Build the Docker image for the central-repo-service | |
- name: Build Docker Image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: false | |
tags: central-repo-service:latest | |
# Step 3: Run the Docker container for the application in the zap-network | |
- name: Run Docker Container | |
run: docker run -d --name central-repo-service --network zap-network -p 8084:8084 central-repo-service:latest | |
# Step 4: Wait for the application to start and be available | |
- name: Wait for Application to Start | |
run: | | |
echo "Waiting for the application to start..." | |
for i in {1..10}; do | |
if curl -s http://localhost:8084 >/dev/null; then | |
echo "Application is up!" | |
break | |
fi | |
echo "Waiting for 10 seconds..." | |
sleep 10 | |
done | |
# Step 5: Run ZAP Full Scan in the same Docker network | |
- name: ZAP Full Scan | |
uses: zaproxy/action-full-scan@v0.11.0 | |
with: | |
target: 'http://central-repo-service:8084' # Target by container name in the zap-network | |
token: ${{ secrets.GITHUB_TOKEN }} | |
cmd_options: '-t http://central-repo-service:8084 -r zap_report.html' | |
# Step 6: Upload the ZAP report as an artifact | |
- name: Upload ZAP Report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: zap-report | |
path: zap_report.html |