-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (57 loc) · 2.03 KB
/
reusable-snyk-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
56
57
58
59
60
61
##
#
name: snyk-dependency-scan
on:
workflow_call:
inputs:
container_image:
type: string
required: false
description: Container image to scan (defaults to branch name)
target_ref:
type: string
required: false
description: Target Reference for Snyk (defaults to branch name)
severity_threshold:
type: string
default: high
description: Severity threshold to fail the build
command:
type: string
default: test
description: Command to run
secrets:
SNYK_TOKEN:
required: false
description: Optional snyk token
jobs:
snyk:
name: Snyk
runs-on: ubuntu-latest
timeout-minutes: 60
env:
snyk_available: ${{ secrets.SNYK_TOKEN != '' && 'true' || 'false' }}
container_image: ${{ inputs.container_image || format('ghcr.io/{0}:{1}', github.repository, github.ref_name) }}
steps:
- name: Checkout repository
if: ${{ env.snyk_available == 'true' }}
uses: actions/checkout@v4
- name: Snyk ${{ inputs.command }}
if: ${{ env.snyk_available == 'true' }}
continue-on-error: true
uses: snyk/actions/golang@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --severity-threshold=${{ inputs.severity_threshold }} --project-name=${{ github.repository }} --target-reference=${{ inputs.target_ref || github.ref_name }}
command: ${{ inputs.command }}
- name: Snyk ${{ inputs.command }} docker image ${{ env.container_image }}
if: ${{ env.snyk_available == 'true' }}
continue-on-error: true
uses: snyk/actions/docker@master
with:
image: ${{ env.container_image }}
args: --file=Dockerfile --severity-threshold=${{ inputs.severity_threshold }} --project-name=${{ github.repository }} --target-reference=${{ inputs.target_ref || github.ref_name }}
command: ${{ inputs.command }}
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}