Skip to content

Commit

Permalink
Make platforms an input
Browse files Browse the repository at this point in the history
  • Loading branch information
efrecon committed Feb 9, 2024
1 parent 839a4ec commit 9b9ab56
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down

0 comments on commit 9b9ab56

Please sign in to comment.