Skip to content

Commit efe6f8a

Browse files
committed
Add boilerplate
1 parent 18c4039 commit efe6f8a

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed

actions/scan-image/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
## 0.1.0 (2025-10-03)
4+
5+
### 🎉 Features
6+
7+
* **scan-image:** add `snyk` and `trivy` vulnerability scanners with a fail condition configuration
8+
* **scan-image:** add [Dockerhub](https://hub.docker.com/) and [Google Artifact Registry](https://cloud.google.com/artifact-registry/docs) as available private sources

actions/scan-image/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# scan-image
2+
3+
This is a composite GitHub Action used to scan your images in search of vulnerabilities.
4+
5+
The goal is to provide developers a way to check if their PR changes, without having to
6+
wait for periodic scans (Faster feedback loop). This can also be used as part of deployment
7+
CI/CD jobs as a way to verify things before shipping to production environments.
8+
9+
<!-- x-release-please-start-version -->
10+
11+
```yaml
12+
name: Scan image for vulnerabilities
13+
jobs:
14+
scan-image:
15+
name: Scan image for vulnerabilities
16+
steps:
17+
- name: Scan image for vulnerabilities
18+
id: scan-image
19+
uses: grafana/shared-workflows/actions/scan-image@scan-image/v0.1.0
20+
with:
21+
image_name: docker.io/hello-world
22+
fail_on: critical
23+
fail_on_threshold: 1
24+
```
25+
26+
<!-- x-release-please-end-version -->

actions/scan-image/action.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Scan Image
2+
description: Composite action to check an image for vulnerabilities
3+
4+
inputs:
5+
image_name:
6+
description: "The name of the image to scan, including the registry e.g. docker.io/hello-world"
7+
required: true
8+
image_source:
9+
description: "The source of the image to scan"
10+
type: choice
11+
options:
12+
- public
13+
- private_dockerhub
14+
- private_gar
15+
default: public
16+
fail_on:
17+
description: "Whether to fail the workflow if vulnerabilities are found"
18+
type: choice
19+
options:
20+
- critical
21+
- high
22+
- medium
23+
- low
24+
default: critical
25+
fail_on_threshold:
26+
description: "The threshold of vulnerabilities to fail the workflow on"
27+
type: integer
28+
default: 1
29+
trivy_version:
30+
description: "The version of Trivy to use (The latest will be used if not provided)"
31+
type: string
32+
33+
outputs:
34+
trivy:
35+
description: "The results of the Trivy scan"
36+
type: string
37+
value: ${{ steps.run-trivy.outputs.results }}
38+
39+
runs:
40+
using: composite
41+
steps:
42+
43+
- name: Login to DockerHub
44+
id: login-to-dockerhub
45+
if: inputs.image_source == 'private_dockerhub'
46+
uses: grafana/shared-workflows/actions/[email protected]
47+
48+
- name: Extract GAR registry
49+
id: extract-gar-registry
50+
if: inputs.image_source == 'private_gar'
51+
shell: bash
52+
run: |
53+
IMAGE_NAME="${{ inputs.image_name }}"
54+
REGISTRY="${IMAGE_NAME%%/*}"
55+
echo "registry=${REGISTRY}" >> $GITHUB_OUTPUT
56+
57+
- name: Login to GAR
58+
id: login-to-gar
59+
if: inputs.image_source == 'private_gar'
60+
uses: grafana/shared-workflows/actions/login-to-gar@login-to-gar/v1.0.0
61+
with:
62+
registry: ${{ steps.extract-gar-registry.outputs.registry }}
63+
64+
- name: Setup Trivy (Latest)
65+
id: setup-trivy-latest
66+
if: inputs.trivy_version == ''
67+
uses: aquasecurity/[email protected]
68+
69+
- name: Setup Trivy (Pinned)
70+
id: setup-trivy-pinned
71+
if: inputs.trivy_version != ''
72+
uses: aquasecurity/[email protected]
73+
with:
74+
version: ${{ inputs.trivy_version }}
75+
76+
- name: Run Trivy
77+
id: run-trivy
78+
shell: bash
79+
run: |
80+
trivy image ${{ inputs.image_name }} -f json > trivy.json
81+
cat trivy.json
82+
echo "results=$(cat trivy.json)" >> $GITHUB_OUTPUT
83+
84+

0 commit comments

Comments
 (0)