diff --git a/action.yml b/action.yml index 00158d2..f737565 100644 --- a/action.yml +++ b/action.yml @@ -30,8 +30,8 @@ inputs: default: "" required: false - image_platforms: - description: "optional additional architectures -comma separated- (right now only linux/amd64 and linux/arm64 are supported)" + alternate_platforms: + description: "optional additional architectures -comma separated- (right now only linux/amd64 and linux/arm64 are supported), linux/amd64 is always set" required: false external_tag: @@ -177,12 +177,22 @@ runs: shell: bash run: if ! (docker context ls | grep -q mycontext) ;then docker context create mycontext; fi + - name: Creating list of platforms for Image build + if: ${{ inputs.build == 'true' }} + shell: bash + id: platforms_list + # This will trim whitespace and remove duplicates if specified, espcially if the user has specified linux/amd64 + run: | + [[ -n "${{ inputs.alternate_platforms }}" ]] && platform_list_temp="linux/amd64,${{ inputs.alternate_platforms }}" || platform_list_temp="linux/amd64" + final_platforms_list=$(echo $platform_list_temp | tr -d ' ' | tr ',' '\n' | sort | uniq | paste -sd ',' -) + echo "image_platforms=${final_platforms_list}" >> $GITHUB_OUTPUT + - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@v3 with: endpoint: mycontext - platforms: ${{ inputs.image_platforms }} + platforms: ${{ steps.platforms_list.outputs.image_platforms }} # Login to registries - name: Login to Artifactory @@ -255,15 +265,6 @@ runs: [[ -n "${{ inputs.image_tag_string_suffix }}" ]] && _suffix="-${{ inputs.image_tag_string_suffix }}" || _suffix="" echo "ver=${_prefix}${{ steps.bump_version.outputs.new_version }}${_suffix}" >> $GITHUB_OUTPUT - - name: Check alternative platforms and strip amd64 - if: ${{ inputs.build == 'true' && inputs.image_platforms != '' }} - shell: bash - id: alternative_platforms - run: | - [[ -n "${{ inputs.image_platforms }}" ]] && _altplatforms=$(echo ${{ inputs.image_platforms }} | sed 's/linux\/amd64,//') || echo "No alternative platforms specified" - echo "DEBUG=${_altplatforms}" - echo "result=${_altplatforms}" >> $GITHUB_OUTPUT - - name: Build container meta id: meta uses: docker/metadata-action@v4 @@ -325,19 +326,7 @@ runs: push: ${{ inputs.dry_run != 'true' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - - name: Optional build container for other platforms - uses: docker/build-push-action@v3 - if: ${{ inputs.build == 'true' && steps.alternative_platforms.outputs.result != '' }} - continue-on-error: true - with: - context: ${{ inputs.context_path }} - file: ${{ inputs.context_path }}/${{ inputs.dockerfile }} - build-args: ${{ inputs.build_argsĀ }} - push: ${{ inputs.dry_run != 'true' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ steps.alternative_platforms.outputs.result }} + platforms: ${{ steps.platforms_list.outputs.image_platforms }} - name: Save image to file uses: docker/build-push-action@v3