Skip to content

Scan Docker images in Snyk Github action #2

Scan Docker images in Snyk Github action

Scan Docker images in Snyk Github action #2

Workflow file for this run

name: CI
on:
push:
tags:
- '*'
branches:
- master
- develop
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- name: Install LZO
run: sudo apt-get install -y lzop liblzo2-dev
- name: Run tests
run: sbt test
- name: Check formatting
run: sbt scalafmtCheck
publish_docker:
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix:
app:
- main
- lzo
- distroless
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- name: Install LZO
run: sudo apt-get install -y lzop liblzo2-dev
- name: Login to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
run: sbt "project ${{ matrix.app }}" docker:publish
create_release:
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- name: Install LZO
run: sudo apt-get install -y lzop liblzo2-dev
- name: Build artifacts
run: |
sbt assembly
- name: Get current version
id: ver
run: |
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')
echo "::set-output name=project_version::$PROJECT_VERSION"
- name: Create GitHub release and attach artifacts
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: true
name: Version ${{ steps.ver.outputs.project_version }}
tag_name: ${{ steps.ver.outputs.project_version }}
files: |
modules/main/target/scala-2.13/snowplow-s3-loader-${{ steps.ver.outputs.project_version }}.jar
modules/lzo/target/scala-2.13/snowplow-s3-loader-lzo-${{ steps.ver.outputs.project_version }}.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}