Files
starter-workflows/code-scanning/trivy.yml
T

48 lines
1.4 KiB
YAML
Raw Normal View History

2021-11-19 16:55:27 +01:00
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: build
on:
push:
branches: [ $default-branch, $protected-branches ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ $default-branch ]
schedule:
- cron: $cron-weekly
2022-01-26 22:42:19 +05:30
permissions:
contents: read
2022-01-13 11:12:14 +05:30
2021-11-19 16:55:27 +01:00
jobs:
build:
2022-01-13 11:12:14 +05:30
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
2021-11-19 16:55:27 +01:00
name: Build
runs-on: "ubuntu-18.04"
steps:
- name: Checkout code
2022-03-28 13:10:48 -04:00
uses: actions/checkout@v3
2021-11-19 16:55:27 +01:00
- name: Build an image from Dockerfile
run: |
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@7b7aa264d83dc58691451798b4d117d53d21edfe
2021-11-19 16:55:27 +01:00
with:
image-ref: 'docker.io/my-organization/my-app:${{ github.sha }}'
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
- name: Upload Trivy scan results to GitHub Security tab
2022-03-31 08:24:35 -04:00
uses: github/codeql-action/upload-sarif@v2
2021-11-19 16:55:27 +01:00
with:
sarif_file: 'trivy-results.sarif'