Bump docker/login-action from 3 to 4 #44
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: Scan Docker Image With Trivy | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| image: | |
| description: "Image to scan with Trivy" | |
| required: false | |
| default: "sadminriley/python-test:latest" | |
| jobs: | |
| trivy-scan: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: | | |
| #docker build -t sadminriley/python-test:${{ github.sha }} . | |
| docker build -t ${{ github.event.inputs.image || 'sadminriley/python-test' }}:${{ github.sha }} . | |
| - name: Setup Trivy | |
| uses: aquasecurity/setup-trivy@v0.2.0 | |
| - name: Run Trivy scan on PR | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| trivy image \ | |
| --severity CRITICAL,HIGH \ | |
| --ignore-unfixed \ | |
| --format table \ | |
| ${{ github.event.inputs.image || 'sadminriley/python-test' }}:${{ github.sha }} \ | |
| > trivy-pr.txt | |
| - name: Publish Trivy Output to Summary | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| if [[ -s trivy-pr.txt ]]; then | |
| { | |
| echo "### Trivy Security Scan" | |
| echo "<details><summary>Click to expand</summary>" | |
| echo "" | |
| echo '```text' | |
| cat trivy-pr.txt | |
| echo '```' | |
| echo "</details>" | |
| } >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "### Trivy Security Scan" >> $GITHUB_STEP_SUMMARY | |
| echo "No CRITICAL or HIGH vulnerabilities found." >> $GITHUB_STEP_SUMMARY | |
| fi |