example-voting-app-pull-v1 #7
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: Sysdig Voting App Image Scans | ||
|
Check failure on line 1 in .github/workflows/sysdig-inline-scan.yml
|
||
| on: | ||
| push: | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| jobs: | ||
| build-and-scan: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| ############################################################ | ||
| # Authenticate Sysdig CLI Scanner | ||
| ############################################################ | ||
| - name: Download Sysdig Scanner (stable) | ||
| run: | | ||
| curl -sL https://download.sysdig.com/scanning/bin/sysdig-cli-scanner/1.24.1/linux/amd64/sysdig-cli-scanner \ | ||
| -o sysdig-cli-scanner | ||
| chmod +x sysdig-cli-scanner | ||
| - name: Verify Sysdig API token exists | ||
| run: | | ||
| if [ -z "${{ secrets.SECURE_API_TOKEN }}" ]; then | ||
| echo "ERROR: Missing SECURE_API_TOKEN secret" | ||
| exit 1 | ||
| fi | ||
| ############################################################ | ||
| # Build Docker images for vote, worker, result | ||
| ############################################################ | ||
| - name: Build vote image | ||
| run: docker build -t vote-app:latest ./vote | ||
| - name: Build worker image | ||
| run: docker build -t worker-app:latest ./worker | ||
| - name: Build result image | ||
| run: docker build -t result-app:latest ./result | ||
| ############################################################ | ||
| # Scan Images with Sysdig CLI Scanner | ||
| ############################################################ | ||
| - name: Scan vote image | ||
| continue-on-error: true | ||
| run: | | ||
| ./sysdig-cli-scanner \ | ||
| --apiurl https://app.us4.sysdig.com/ \ | ||
| docker://vote-app:latest | ||
| env: | ||
| SECURE_API_TOKEN: ${{ secrets.SECURE_API_TOKEN }} | ||
| - name: Scan worker image | ||
| continue-on-error: true | ||
| run: | | ||
| ./sysdig-cli-scanner \ | ||
| --apiurl https://app.us4.sysdig.com/ \ | ||
| docker://worker-app:latest | ||
| env: | ||
| SECURE_API_TOKEN: ${{ secrets.SECURE_API_TOKEN }} | ||
| - name: Scan result image | ||
| continue-on-error: true | ||
| run: | | ||
| ./sysdig-cli-scanner \ | ||
| --apiurl https://app.us4.sysdig.com/ \ | ||
| docker://result-app:latest | ||
| env: | ||
| SECURE_API_TOKEN: ${{ secrets.SECURE_API_TOKEN }} | ||
| - name: Security gate decision | ||
| run: | | ||
| FAILED=0 | ||
| for scan in vote worker result; do | ||
| if [[ "${{ steps['scan_' + scan].outcome }}" == "failure" ]]; then | ||
| echo "❌ $scan image failed Sysdig policy evaluation" | ||
| FAILED=1 | ||
| else | ||
| echo "✅ $scan image passed Sysdig policies" | ||
| fi | ||
| done | ||
| if [[ "$FAILED" -eq 1 ]]; then | ||
| echo "Blocking deployment due to policy violations" | ||
| exit 1 | ||
| else | ||
| echo "All images passed security policies" | ||
| fi | ||