diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index e5fa463..be6862d 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -22,6 +22,11 @@ on: required: false type: string default: 'ubuntu-latest' + platforms: + description: 'Platforms to build for, comma separated list of arch/os pairs' + required: false + type: string + default: 'linux/amd64,linux/arm64' secrets: username: description: 'username at registry' @@ -34,20 +39,33 @@ env: REGISTRY_IMAGE: ${{ inputs.image }} jobs: + convert: + runs-on: ${{ inputs.runs-on }} + outputs: + platforms: ${{ steps.convert.outputs.platforms }} + steps: + - + name: Convert Platforms + id: convert + run: | + platforms=${{ inputs.platforms }} + inside=$(printf %s\\n "$platforms" | sed -E -e 's/,/\", \"/g' -e 's/\" +/\"/g' -e 's/ +\"/\"/g') + printf 'platforms=["%s"]' "$inside" >> $GITHUB_OUTPUT + build: runs-on: ${{ inputs.runs-on }} + needs: + - convert strategy: fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm64 + platform: ${{ needs.convert.outputs.platforms }} steps: - name: Prepare id: platform run: | - platform=${{ matrix.platform }} + platform=${{ needs.convert.outputs.platforms }} echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - name: Checkout @@ -77,7 +95,7 @@ jobs: uses: docker/build-push-action@v5 with: context: . - platforms: ${{ matrix.platform }} + platforms: ${{ needs.convert.outputs.platforms }} labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true file: ${{ inputs.file }}