Skip to content

Commit 6b75d68

Browse files
committed
use pre-step
1 parent c06daf9 commit 6b75d68

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

.github/workflows/builds.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,13 @@ on:
4444
required: false
4545

4646
jobs:
47-
docker-push:
48-
name: ${{ matrix.role }} images
47+
# matrix_builder generates a matrix that includes the roles selected in the input
48+
matrix_builder:
4949
runs-on: ubuntu-latest
50-
51-
# setup jobs for each role
52-
strategy:
53-
fail-fast: false
54-
matrix:
55-
role: ${{ steps.set-matrix.outputs.roles }}
56-
50+
outputs:
51+
matrix: ${{ steps.generate.outputs.matrix }}
5752
steps:
58-
# select the roles to add to the matrix based on the input selections
59-
- id: set-matrix
53+
- id: generate
6054
run: |
6155
roles=()
6256
if [[ "${{ inputs.build_access }}" = "true" ]]; then
@@ -78,7 +72,18 @@ jobs:
7872
roles+=( "observer" )
7973
fi
8074
rolesJSON=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${X[@]}")
81-
echo "roles=${rolesJSON}" >> $GITHUB_OUTPUT
75+
echo "matrix={\"roles\":$(echo $rolesJSON)}" >> $GITHUB_OUTPUT
76+
docker-push:
77+
name: ${{ matrix.role }} images
78+
runs-on: ubuntu-latest
79+
needs: matrix_builder
80+
81+
# setup jobs for each role
82+
strategy:
83+
fail-fast: false
84+
matrix: ${{ fromJson(needs.matrix_builder.outputs.matrix) }}
85+
86+
steps:
8287
- name: Setup Go
8388
uses: actions/setup-go@v2
8489
with:

0 commit comments

Comments
 (0)