Add GetContainerPlatforms a useful reusable workflow to get #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Get Container Platforms | |
| description: 'Extracts supported platforms from a Docker image manifest' | |
| inputs: | |
| image: | |
| description: 'Image name to inspect' | |
| required: true | |
| outputs: | |
| platforms: | |
| description: 'Comma-separated list of platforms' | |
| value: ${{ steps.set-env.outputs.platforms }} | |
| build-matrix: | |
| description: 'JSON array of platforms' | |
| value: ${{ steps.set-env.outputs.build-matrix }} | |
| runs: | |
| using: 'composite' | |
| steps: | |
| - name: Set dynamic environment | |
| id: set-env | |
| run: | | |
| PLATFORMS="$(docker manifest inspect ${{ inputs.image }} | \ | |
| jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \ | |
| sort -u | grep -v unknown | paste -sd ',')" | |
| BUILD_MATRIX="$(echo ${PLATFORMS} | tr ',' '\n' | jq -R . | jq -s . | tr '\n' ' ')" | |
| echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT | |
| echo "build-matrix=${BUILD_MATRIX}" >> $GITHUB_OUTPUT | |
| shell: bash |