Skip to content

Commit

Permalink
use matrix strategy to DRY workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
CamJN committed Nov 20, 2023
1 parent 0ecebb0 commit f8ebc4e
Showing 1 changed file with 17 additions and 191 deletions.
208 changes: 17 additions & 191 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,210 +11,36 @@ defaults:
shell: bash

jobs:
build-customizable:
build:
name: "build-${{ matrix.img }}"
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
img:
- full
- customizable
- nodejs
- jruby94
- jruby93
- ruby32
- ruby31
- ruby30
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_customizable
run: make build_customizable

- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_customizable

build-ruby30:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_ruby30
run: make build_ruby30

- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_ruby30

build-ruby31:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_ruby31
run: make build_ruby31

- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_ruby31

build-ruby32:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_ruby32
run: make build_ruby32

- name: "Run make build_${{ matrix.img }}"
run: "make build_${{ matrix.img }}"
- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_ruby32

build-jruby93:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_jruby93
run: make build_jruby93

- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_jruby93

build-jruby94:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_jruby94
run: make build_jruby94

- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_jruby94

build-nodejs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_nodejs
run: make build_nodejs

- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_nodejs

build-full:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Purge containers
run: 'docker kill $(docker ps -q) || exit 0'

- name: Enable docker multiarch
run: 'docker run --privileged --rm tonistiigi/binfmt --install all'

- name: Run make build_full
run: make build_full

- name: Log in to the Container registry
if: ${{ github.event.pull_request.merged || github.actor == 'CamJN' }}
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push to github container registry
run: make release_full
run: "make release_${{ matrix.img }}"

0 comments on commit f8ebc4e

Please sign in to comment.