-
Notifications
You must be signed in to change notification settings - Fork 8
56 lines (54 loc) · 1.58 KB
/
scan_images.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Scan existing images
on:
schedule:
- cron: '10 3 * * SAT'
workflow_dispatch:
permissions:
contents: read
packages: read
security-events: write
jobs:
build:
strategy:
fail-fast: false
matrix:
label:
- 'latest'
- 'beta'
name: ${{ matrix.label }}
runs-on: ubuntu-22.04
steps:
- name: Docker login
if: ${{ env.TAGS }}
env:
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
echo ${GHCR_TOKEN} |
docker login ghcr.io -u ${{ github.repository_owner }}
--password-stdin
- name: Define image name
run: |
echo "IMAGE=ghcr.io/${{ github.repository_owner }}/hello-ghcr-meow:${{ matrix.label }}" >>${GITHUB_ENV}
- name: Get container image
run: |
docker pull ${IMAGE}
- name: Read image revision
run: |
echo "IMAGE_REF=$(docker image inspect --format '{{ index .Config.Labels "org.opencontainers.image.revision" }}' ${IMAGE})" >>${GITHUB_ENV}
- uses: actions/checkout@v4
with:
ref: ${{ env.IMAGE_REF }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: '${{ env.IMAGE }}'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
- name: Docker logout
if: always()
run: |
docker logout ghcr.io