Skip to content

Commit 68b5370

Browse files
feat: 🚀 Docker scout reusable workflow (#96)
1 parent 1c231ea commit 68b5370

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
name: docker-scout
3+
on:
4+
workflow_call:
5+
inputs:
6+
IMAGES:
7+
description: 'Dockerhub repository name'
8+
required: true
9+
type: string
10+
IMAGE_TAG:
11+
description: 'Image tag for latest docker image'
12+
type: string
13+
default: latest
14+
COMPARE_TAG:
15+
description: 'provide the tag of the image you like to compare with'
16+
required: true
17+
type: string
18+
# Filter flags
19+
IGNORE-BASE:
20+
description: 'Ignore vulnerabilities from base image'
21+
default: false
22+
type: string
23+
IGNORE-UNCHANGED:
24+
description: 'Filter out unchanged packages'
25+
default: true
26+
type: string
27+
ONLY-FIXED:
28+
description: 'Filter to fixable CVEs'
29+
default: false
30+
type: string
31+
WRITE-COMMENT:
32+
description: 'Write the output as a Pull Request comment'
33+
default: true
34+
type: string
35+
secrets:
36+
DOCKERHUB_USERNAME:
37+
description: 'dockerhub username'
38+
required: true
39+
DOCKERHUB_PASSWORD:
40+
description: 'dockerhub password'
41+
required: true
42+
TOKEN:
43+
description: 'Github Token'
44+
required: true
45+
46+
jobs:
47+
docker-scout:
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
- name: Checkout git repo
52+
uses: actions/checkout@v4
53+
54+
- name: Setup Docker buildx
55+
uses: docker/[email protected]
56+
with:
57+
driver-opts: |
58+
image=moby/buildkit:v0.10.6
59+
60+
- name: Login to Docker Hub
61+
uses: docker/login-action@v3
62+
with:
63+
username: ${{ secrets.DOCKERHUB_USERNAME }}
64+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
65+
66+
- name: Build docker image
67+
env:
68+
IMAGE_TAG: ${{ inputs.IMAGE_TAG }}
69+
images: ${{ inputs.IMAGES }}
70+
run: |
71+
docker build -t $images:$IMAGE_TAG .
72+
# docker push $images:$IMAGE_TAG
73+
74+
- name: Docker Scout
75+
id: docker-scout
76+
uses: docker/scout-action@v1
77+
with:
78+
command: cves,recommendations,compare
79+
to-latest: false
80+
to: ${{ inputs.IMAGES }}:${{ inputs.COMPARE_TAG }}
81+
image: ${{ inputs.IMAGES }}:${{ inputs.IMAGE_TAG }}
82+
ignore-base: ${{ inputs.IGNORE-BASE }}
83+
ignore-unchanged: ${{ inputs.IGNORE-BASE }}
84+
only-fixed: ${{ inputs.ONLY-FIXED }}
85+
write-comment: ${{ inputs.WRITE-COMMENT }}
86+
github-token: ${{ secrets.TOKEN }}
87+
...

‎docs/docker-scout.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Docker-Scout Workflow
2+
#### [Docker scout workflow reference](https://github.com/clouddrove/github-shared-workflows/blob/master/.github/workflows/docker-scout.yml)
3+
4+
This workflow involves locally scanning a Docker image and then comparing the latest Docker image with a specified image within the same repository. Workflows have been added in `.github/workflows/docker-compose.yml`.
5+
6+
#### Usage
7+
8+
This workflow is designed to locally build and scan a Docker image, offering vulnerability information, recommended fixes for the latest images, and the ability to compare the latest image with a specified image within the same repository.
9+
#### Example for scan and push docker image on Dockerhub
10+
11+
```yaml
12+
name: Docker-scout Workflow
13+
# This permission are helpful for pushing vulnerability in security tab
14+
permissions:
15+
contents: read
16+
packages: write
17+
pull-requests: write
18+
19+
on:
20+
workflow_dispatch:
21+
22+
jobs:
23+
docker-scout:
24+
uses: clouddrove/github-shared-workflows/.github/workflows/docker-scout.yml@master
25+
with:
26+
IMAGES: # Specify the dockerhub repository name
27+
IMAGE_TAG: # Give the tag to the latest image you want to build
28+
COMPARE_TAG: # Specify the tag of the image you want to compare with within the same repository.
29+
secrets:
30+
DOCKERHUB_USERNAME: # Dockerhub username
31+
DOCKERHUB_PASSWORD: # Dockerhub password
32+
TOKEN: # GitHub token
33+
```

0 commit comments

Comments
 (0)