-
Notifications
You must be signed in to change notification settings - Fork 77
55 lines (47 loc) · 1.6 KB
/
docker-scan.yml
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
name: Build and Scan Docker Images
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build-and-scan:
name: ${{ matrix.folder }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
folder: ["curl", "httpd", "locust", "nginx", "wireshark"]
steps:
- name: Checkout Repository
uses: actions/[email protected]
- name: Log in to Docker Hub
# Required for Docker Scout
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker Image
run: |
FILES=$(find ./${{ matrix.folder }} -type f -iname 'dockerfile*')
if [ -z "$FILES" ]; then
echo "No Dockerfiles found in folder: ${{ matrix.folder }}. Skipping build."
exit 1
fi
for FILE in $FILES; do
IMAGE_NAME="${{ matrix.folder }}-$(basename $FILE | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]-')"
echo "Building Docker image: $IMAGE_NAME using $FILE"
docker build -t $IMAGE_NAME -f $FILE ./${{ matrix.folder }}
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV
done
- name: Scan Docker Image
uses: docker/[email protected]
with:
image: ${{ env.IMAGE_NAME }}
command: cves,recommendations
sarif-file: sarif.output.json
- name: Export the Results
uses: actions/[email protected]
with:
name: docker-scout-sarif-${{ matrix.folder }}
path: sarif.output.json