Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically builds docker build matrix #59

Merged
merged 7 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/workflows/docker-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,25 @@ on:
- master

jobs:
build-on-linux:
strategy:
matrix:
project: [armeria, dropwizard, ratpack, 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
name: Generate outputs.matrix from pom.xml listing
run: echo "::set-output name=matrix::{\"include\":$(.github/workflows/projects-as-json)}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty slick in a magical way

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧙

build-and-verify-docker:
name: Build and verify Docker images
needs: discover-projects
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.discover-projects.outputs.matrix) }}
steps:
- name: Install Docker
uses: docker-practice/actions-setup-docker@master
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/projects-as-json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -ue

# Make a string like: [{"project":"armeria"},{"project":"dropwizard"}]
ls */pom.xml|sed 's~\(.*\)/pom.xml~{"project":"\1"}~g'|tr '\n' ','|sed 's/\(.*\),$/[\1]/'
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