Skip to content

Commit

Permalink
Dynamically builds docker build matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cole committed Oct 16, 2020
1 parent d94c7ce commit e454219
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/docker-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,28 @@ on:
- master

jobs:
build-on-linux:
strategy:
matrix:
project: [armeria, dropwizard, webmvc25-jetty, webmvc3-jetty, webmvc4-boot, webmvc4-jetty]
discover-projects:
name: Build project matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Sources
uses: actions/checkout@v2
with:
fetch-depth: 1
- id: set-matrix
run: |
# Make a string like: [{"project":"armeria"},{"project":"dropwizard"}]
PROJECTS=$(ls */pom.xml|sed 's~\(.*\)/pom.xml~{"project":"\1"}~g'|tr '\n' ','|sed 's/\(.*\),$/[\1]/')
echo "::set-output name=matrix::{\"include\":[${PROJECTS}]}"
build-and-verify-docker:
name: Build and verify Docker images
needs: discover-projects
runs-on: ubuntu-latest
strategy:
matrix:
matrix: ${{ fromJson(needs.discover-projects.outputs.matrix) }}
steps:
- name: Install Docker
uses: docker-practice/actions-setup-docker@master
Expand All @@ -25,10 +41,6 @@ jobs:
path: ~/.docker
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile') }}
restore-keys: ${{ runner.os }}-docker
- name: Checkout Repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Build Docker image openzipkin/example-brave:${{ matrix.project }}-test
run: docker/build_image ${{ matrix.project }} ${{ matrix.project }}-test
- name: Verify Docker image openzipkin/example-brave:${{ matrix.project }}-test
Expand Down
4 changes: 3 additions & 1 deletion docker/hooks/build
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh -v
#!/bin/sh -x

set -ue

# This hook is called with the current directory set to the same as the Dockerfile, so we go back
# to top level.
Expand Down
4 changes: 3 additions & 1 deletion docker/hooks/push
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/sh -v
#!/bin/sh -x

set -ue

# Override push to avoid pushing a latest tag. We use tags for each example.
if [ "$DOCKER_REPO" = "index.docker.io/openzipkin/example-brave" ]; then
Expand Down

0 comments on commit e454219

Please sign in to comment.