Skip to content

Commit d081c1c

Browse files
Add Snyk security scan workflow
1 parent 21637ee commit d081c1c

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Snyk Security Scan
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
schedule:
9+
# Run daily at 2 AM UTC
10+
- cron: '0 2 * * *'
11+
workflow_dispatch:
12+
13+
jobs:
14+
snyk-scan:
15+
runs-on: ubuntu-latest
16+
environment: snyk
17+
18+
permissions:
19+
contents: read
20+
security-events: write
21+
actions: read
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '22'
31+
32+
- name: Verify Snyk token exists
33+
run: |
34+
if [ -z "${{ secrets.SNYK_TOKEN }}" ]; then
35+
echo "❌ ERROR: SNYK_TOKEN secret is not set"
36+
exit 1
37+
else
38+
echo "✅ SNYK_TOKEN secret is configured"
39+
fi
40+
41+
- name: Install dependencies
42+
if: hashFiles('package.json') != ''
43+
run: npm install
44+
45+
- name: Run Snyk to check for vulnerabilities
46+
uses: snyk/actions/node@master
47+
continue-on-error: true
48+
env:
49+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
50+
with:
51+
args: --all-projects --severity-threshold=medium
52+
53+
- name: Run Snyk Monitor (track project)
54+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
55+
uses: snyk/actions/node@master
56+
env:
57+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
58+
with:
59+
command: monitor
60+
args: --all-projects

0 commit comments

Comments
 (0)