Skip to content

Publish ARM docker images in Github action #32

Publish ARM docker images in Github action

Publish ARM docker images in Github action #32

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 "project main" test
sbt "project lzo" test
- name: Check formatting
run: sbt scalafmtCheck
publish_docker:
needs: test
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix:
sbtProject:
- main
- lzo
- distroless
include:
- sbtProject: main
runSnyk: false
dockerTagSuffix: ""
- sbtProject: lzo
runSnyk: true
dockerTagSuffix: "-lzo"
- sbtProject: distroless
runSnyk: true
dockerTagSuffix: "-distroless"
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: adopt
- name: Login to Docker Hub
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Stage the Docker build
run: sbt "project ${{ matrix.sbtProject}}" docker:stage
- name: Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: snowplow/snowplow-s3-loader
tags: |
type=raw,value=latest${{ matrix.dockerTagSuffix }},enable=${{ !contains(github.ref_name, 'rc') }}
type=raw,value=${{ github.ref_name }}${{ matrix.dockerTagSuffix }}
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Push image
uses: docker/build-push-action@v2
with:
context: modules/${{ matrix.sbtProject }}/target/docker/stage
file: modules/${{ matrix.sbtProject }}/target/docker/stage/Dockerfile
platforms: linux/amd64,linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
push: true
- name: Build local image, which is needed to run Snyk
if: ${{ !contains(github.ref_name, 'rc') && fromJSON(matrix.runSnyk) }}
run: sbt "project ${{ matrix.sbtProject }}" docker:publishLocal
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/docker@master
if: ${{ !contains(github.ref_name, 'rc') && fromJSON(matrix.runSnyk) }}
with:
image: "snowplow/snowplow-s3-loader:${{ github.ref_name }}${{ matrix.dockerTagSuffix }}"
args: "--app-vulns --org=99605b41-ca0f-42c9-a9ff-45c201a10a26"
command: monitor
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
create_release:
needs: test
if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'rc') }}
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 }}