Basic Swapping with titan #96
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: Security Scan | |
| on: | |
| pull_request: | |
| concurrency: | |
| group: security-scan-${{ github.event.pull_request.head.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run Trivy vulnerability scanner in repo mode | |
| uses: aquasecurity/[email protected] | |
| with: | |
| scan-type: 'fs' | |
| ignore-unfixed: true | |
| output: trivy-results.txt | |
| severity: 'CRITICAL,HIGH' | |
| exit-code: 0 | |
| - name: Read scan summary if results are non-empty | |
| id: trivy_summary | |
| run: | | |
| if [ "$(wc -l < trivy-results.txt)" -gt 1 ]; then | |
| echo 'should_comment=true' >> $GITHUB_OUTPUT | |
| echo 'summary<<EOF' >> $GITHUB_OUTPUT | |
| cat trivy-results.txt >> $GITHUB_OUTPUT | |
| echo 'EOF' >> $GITHUB_OUTPUT | |
| else | |
| echo 'should_comment=false' >> $GITHUB_OUTPUT | |
| fi | |
| - name: Comment on PR | |
| if: steps.trivy_summary.outputs.should_comment == 'true' | |
| uses: thollander/actions-comment-pull-request@v3 | |
| with: | |
| comment-tag: "trivy-scan" | |
| message: | | |
| 🚨 **Trivy Scan Summary** | |
| ``` | |
| ${{ steps.trivy_summary.outputs.summary }} | |
| ``` | |
| - name: Fail if CRITICAL or HIGH vulnerabilities found | |
| run: | | |
| if grep -qE 'CRITICAL|HIGH' trivy-results.txt; then | |
| echo "❌ CRITICAL or HIGH vulnerabilities found." | |
| exit 1 | |
| else | |
| echo "✅ No critical/high vulnerabilities." | |
| fi |