Create docker-publish.yml #17
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: Scan Docker Image with Trivy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
trivy_scan: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: Prepare report file | |
run: touch trivy-image-report.txt | |
- name: Run Trivy vulnerability scanner on Docker image | |
uses: aquasecurity/trivy-action@master | |
with: | |
scan-type: 'image' | |
image-ref: 'ezio22/myazurefunctionapp:latest' | |
format: 'table' | |
exit-code: '1' | |
ignore-unfixed: false | |
severity: 'MEDIUM,HIGH,CRITICAL' | |
output: 'trivy-image-report.txt' | |
- name: Display Trivy scan results | |
run: | | |
if [ -s trivy-image-report.txt ]; then | |
cat trivy-image-report.txt | |
else | |
echo "Trivy report is empty." | |
fi | |
- name: Upload Trivy scan results | |
if: always() | |
uses: actions/upload-artifact@v2 | |
with: | |
name: trivy-report | |
path: trivy-image-report.txt |