1818 description : ' Determines wheather this workflow will also deploy (login and push).'
1919 required : true
2020 type : boolean
21- matrix_version :
22- description : ' The version build matrix as JSON string (list of objects [{NAME,VERSION}]).'
23- required : true
24- type : string
25- matrix_arch :
26- description : ' The architecture build matrix as JSON string (list of architectures).'
21+ matrix :
22+ description : ' The version build matrix as JSON string ( list of objects: [{NAME, VERSION[], ARCH[]}] ).'
2723 required : true
2824 type : string
29- matrix_refs :
25+ refs :
3026 description : ' The ref build matrix as JSON string (list of git refs to build/deploy).'
3127 required : false
3228 type : string
5450 has_refs : ${{ steps.set-matrix.outputs.has_refs }}
5551 matrix_build : ${{ steps.set-matrix.outputs.matrix_build }}
5652 matrix_deploy : ${{ steps.set-matrix.outputs.matrix_deploy }}
57- manifest : ${{ steps.set-manifest-arch.outputs.manifest }}
5853 if : inputs.enabled
5954 steps :
6055 - name : " [Set-Output] Set Docker login capabilities"
@@ -74,51 +69,42 @@ jobs:
7469 id : set-matrix
7570 shell : bash
7671 run : |
77- if [ "${{ inputs.matrix_refs }}" != "" ]; then
72+ if [ "${{ inputs.refs }}" != "" ]; then
7873 MATRIX_BUILD="$( \
7974 jq -M -c \
80- --argjson refs '${{ inputs.matrix_refs }}' \
81- --argjson arches '${{ inputs.matrix_arch }}' \
82- 'map({name:.NAME, version:.VERSION, arch:$arches[], refs:$refs[]})' <<<'${{ inputs.matrix_version }}' \
75+ --argjson refs '${{ inputs.refs }}' \
76+ 'map({name:.NAME, version:.VERSION[], arch:.ARCH[], refs:$refs[]})' <<<'${{ inputs.matrix }}' \
8377 )"
8478 MATRIX_DEPLOY="$( \
8579 jq -M -c \
86- --argjson refs '${{ inputs.matrix_refs }}' \
87- 'map({name:.NAME, version:.VERSION, refs:$refs[]})' <<<'${{ inputs.matrix_version }}' \
80+ --argjson refs '${{ inputs.refs }}' \
81+ 'map({name:.NAME, version:.VERSION[] , refs:$refs[]})' <<<'${{ inputs.matrix }}' \
8882 )"
8983 echo "::set-output name=matrix_build::${MATRIX_BUILD}"
9084 echo "::set-output name=matrix_deploy::${MATRIX_DEPLOY}"
9185 echo "::set-output name=has_refs::1"
9286 else
9387 MATRIX_BUILD="$( \
9488 jq -M -c \
95- --argjson arches '${{ inputs.matrix_arch }}' \
96- 'map({name:.NAME, version:.VERSION, arch:$arches[]})' <<<'${{ inputs.matrix_version }}' \
89+ 'map({name:.NAME, version:.VERSION[], arch:.ARCH[]})' <<<'${{ inputs.matrix }}' \
9790 )"
9891 MATRIX_DEPLOY="$( \
9992 jq -M -c \
100- 'map({name:.NAME, version:.VERSION})' <<<'${{ inputs.matrix_version }}' \
93+ 'map({name:.NAME, version:.VERSION[] })' <<<'${{ inputs.matrix }}' \
10194 )"
10295 echo "::set-output name=matrix_build::${MATRIX_BUILD}"
10396 echo "::set-output name=matrix_deploy::${MATRIX_DEPLOY}"
10497 echo "::set-output name=has_refs::0"
10598 fi
10699
107- - name : " [Set-Output] Set Manifest 'Arch'"
108- id : set-manifest-arch
109- run : |
110- ARCH="$( echo ${{ inputs.matrix_arch }} | sed 's/"//g' | sed 's/\[//g' | sed 's/\]//g' | sed 's/ //g' )"
111- echo "::set-output name=manifest::${ARCH}"
112-
113100 - name : " [DEBUG] Workflow Inputs"
114101 shell : bash
115102 run : |
116103 echo 'name: ${{ inputs.name }} '
117104 echo 'enabled: ${{ inputs.enabled }} '
118105 echo 'can_deploy: ${{ inputs.can_deploy }} '
119- echo 'matrix_version: ${{ inputs.matrix_version }} '
120- echo 'matrix_refs: ${{ inputs.matrix_refs }} '
121- echo 'matrix_arch: ${{ inputs.matrix_arch }} '
106+ echo 'matrix: ${{ inputs.matrix }} '
107+ echo 'refs: ${{ inputs.refs }} '
122108
123109 - name : " [DEBUG] Determined Settings"
124110 shell : bash
@@ -127,7 +113,6 @@ jobs:
127113 echo 'has_refs=${{ steps.set-matrix.outputs.has_refs }}'
128114 echo 'matrix_build=${{ steps.set-matrix.outputs.matrix_build }}'
129115 echo 'matrix_deploy=${{ steps.set-matrix.outputs.matrix_deploy }}'
130- echo 'manifest=${{ steps.set-manifest-arch.outputs.manifest }}'
131116
132117 # -----------------------------------------------------------------------------------------------
133118 # JOB (2/3): BUILD
@@ -236,6 +221,19 @@ jobs:
236221 id : tag
237222 uses : cytopia/docker-tag-action@v0.4.7
238223
224+ - name : " [SETUP] Determine manifest arches
225+ id: manifest
226+ run: |
227+ ARCHES=" $( echo ${{ inputs.matrix }} \
228+ | jq 'group_by(.NAME, .VERSION, .ARCH)' \
229+ | jq 'map({NAME : .[].NAME, VERSION: .[].VERSION[], ARCHES: .[].ARCH|join(",")})' \
230+ | jq '.[] | select(.NAME=="${{ matrix.name }}" and .VERSION=="${{ matrix.version }}") | .ARCHES' \
231+ | jq -c -M \
232+ )"
233+ echo "::set-output name=arches::${ARCHES}"
234+ echo "ARCHES : ${ARCHES}"
235+
236+
239237 # ------------------------------------------------------------
240238 # Deploy
241239 # ------------------------------------------------------------
@@ -249,7 +247,7 @@ jobs:
249247 uses : cytopia/shell-command-retry-action@v0.1.2
250248 with :
251249 command : |
252- make manifest-create NAME=${{ matrix.name }} VERSION=${{ matrix.version }} ARCHES=${{ needs.configure .outputs.manifest }} TAG=${{ steps.tag.outputs.docker-tag }}
250+ make manifest-create NAME=${{ matrix.name }} VERSION=${{ matrix.version }} ARCHES=${{ steps.manifest .outputs.arches }} TAG=${{ steps.tag.outputs.docker-tag }}
253251
254252 - name : " [DEPLOY] Publish Docker manifest: ${{ steps.tag.outputs.docker-tag }}"
255253 uses : cytopia/shell-command-retry-action@v0.1.2
0 commit comments