Skip to content

Commit

Permalink
simplfy yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarak Ben Youssef committed Mar 14, 2024
1 parent 99cfed3 commit 36aaa12
Showing 1 changed file with 3 additions and 83 deletions.
86 changes: 3 additions & 83 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,100 +5,20 @@ name: Build Node Docker Images
on:
workflow_dispatch:
inputs:
tag:
type: string
description: 'Git tag/commit'
required: true
docker_tag:
type: string
description: 'Docker tag'
required: true
# GHA doesn't support multi-selects, so simulating it with one boolean for each option
build_access:
type: boolean
description: 'Access'
required: false
build_collection:
type: boolean
description: 'Collection'
required: false
build_consensus:
type: boolean
description: 'Consensus'
required: false
build_execution:
type: boolean
description: 'Execution'
required: false
build_verification:
type: boolean
description: 'Verification'
required: false
build_observer:
type: boolean
description: 'Observer'
required: false
# GHA allows only up to 10 inputs - regroup two entries in one
include_alternative_builds:
type: boolean
description: 'Build amd64 `without_adx` and `without_netgo_without_adx` images, and arm64 images'
required: false

jobs:
# matrix_builder generates a matrix that includes the roles selected in the input
matrix_builder:
name: Setup build jobs
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- name: Print all input variables
run: echo '${{ toJson(inputs) }}' | jq

- id: generate
run: |
roles=()
if [[ "${{ inputs.build_access }}" = "true" ]]; then
roles+=( "access" )
fi
if [[ "${{ inputs.build_collection }}" = "true" ]]; then
roles+=( "collection" )
fi
if [[ "${{ inputs.build_consensus }}" = "true" ]]; then
roles+=( "consensus" )
fi
if [[ "${{ inputs.build_execution }}" = "true" ]]; then
roles+=( "execution" )
fi
if [[ "${{ inputs.build_verification }}" = "true" ]]; then
roles+=( "verification" )
fi
if [[ "${{ inputs.build_observer }}" = "true" ]]; then
roles+=( "observer" )
fi
rolesJSON=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${roles[@]}")
echo "matrix={\"role\":$(echo $rolesJSON)}" >> $GITHUB_OUTPUT
docker-push:
name: ${{ matrix.role }} images
name: images
runs-on: ubuntu-latest
needs: matrix_builder

# setup jobs for each role
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.matrix_builder.outputs.matrix) }}

steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.20'

- name: Checkout repo
uses: actions/checkout@v2
with:
ref: ${{ inputs.tag }}

# Provide Google Service Account credentials to Github Action, allowing interaction with the Google Container Registry
# Logging in as github-actions@dl-flow.iam.gserviceaccount.com
Expand All @@ -114,7 +34,7 @@ jobs:
- name: Build/Push
env:
IMAGE_TAG: ${{ inputs.docker_tag }}
IMAGE_TAG: haswell_test
run: |
make docker-build docker-push
Expand Down

0 comments on commit 36aaa12

Please sign in to comment.