Skip to content

Commit 32e4638

Browse files
committed
Scan Docker images in Snyk Github action (close #285)
1 parent f24499b commit 32e4638

File tree

3 files changed

+123
-92
lines changed

3 files changed

+123
-92
lines changed

.github/workflows/ci.yml

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
branches:
8+
- master
9+
- develop
10+
pull_request:
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Set up JDK 11
20+
uses: actions/setup-java@v2
21+
with:
22+
java-version: 11
23+
distribution: adopt
24+
25+
- name: Install LZO
26+
run: sudo apt-get install -y lzop liblzo2-dev
27+
28+
- name: Run tests
29+
run: |
30+
sbt "project main" test
31+
sbt "project lzo" test
32+
33+
- name: Check formatting
34+
run: sbt scalafmtCheck
35+
36+
publish_docker:
37+
needs: test
38+
if: startsWith(github.ref, 'refs/tags/')
39+
runs-on: ubuntu-latest
40+
strategy:
41+
matrix:
42+
app:
43+
- main
44+
- lzo
45+
- distroless
46+
include:
47+
- suffix: ""
48+
- app: lzo
49+
run_snyk: ${{ !contains(github.ref, 'rc') }}
50+
- app: distroless
51+
run_snyk: ${{ !contains(github.ref, 'rc') }}
52+
53+
steps:
54+
- uses: actions/checkout@v2
55+
56+
- name: Set up JDK 11
57+
uses: actions/setup-java@v2
58+
with:
59+
java-version: 11
60+
distribution: adopt
61+
62+
- name: Install LZO
63+
run: sudo apt-get install -y lzop liblzo2-dev
64+
65+
- name: Login to Docker Hub
66+
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
67+
env:
68+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
69+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
70+
71+
- name: Publish to Docker Hub
72+
run: sbt "project ${{ matrix.app }}" docker:publish
73+
74+
- name: Build local image, which is needed to run Snyk
75+
if: matrix.run_snyk
76+
run: sbt "project ${{ matrix.app }}" docker:publishLocal
77+
- name: Run Snyk to check for vulnerabilities
78+
uses: snyk/actions/docker@master
79+
if: matrix.run_snyk
80+
with:
81+
image: "snowplow/snowplow-s3-loader:${{ github.ref_name }}-${{ matrix.app }}"
82+
args: "--app-vulns --org=data-processing-new"
83+
command: monitor
84+
env:
85+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
86+
87+
create_release:
88+
needs: test
89+
if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') }}
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v2
94+
95+
- name: Set up JDK 11
96+
uses: actions/setup-java@v2
97+
with:
98+
java-version: 11
99+
distribution: adopt
100+
101+
- name: Install LZO
102+
run: sudo apt-get install -y lzop liblzo2-dev
103+
104+
- name: Build artifacts
105+
run: |
106+
sbt assembly
107+
- name: Get current version
108+
id: ver
109+
run: |
110+
export PROJECT_VERSION=$(sbt version -Dsbt.log.noformat=true | perl -ne 'print "$1\n" if /info.*(\d+\.\d+\.\d+[^\r\n]*)/' | tail -n 1 | tr -d '\n')
111+
echo "::set-output name=project_version::$PROJECT_VERSION"
112+
- name: Create GitHub release and attach artifacts
113+
uses: softprops/action-gh-release@v1
114+
with:
115+
draft: true
116+
prerelease: true
117+
name: Version ${{ steps.ver.outputs.project_version }}
118+
tag_name: ${{ steps.ver.outputs.project_version }}
119+
files: |
120+
modules/main/target/scala-2.13/snowplow-s3-loader-${{ steps.ver.outputs.project_version }}.jar
121+
modules/lzo/target/scala-2.13/snowplow-s3-loader-lzo-${{ steps.ver.outputs.project_version }}.jar
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/snyk.yml

-20
This file was deleted.

.github/workflows/test_and_publish.yml

-72
This file was deleted.

0 commit comments

Comments
 (0)