Skip to content

Commit

Permalink
Merge pull request #52 from draios/feat-add-other-platforms-fix
Browse files Browse the repository at this point in the history
Platform fix
  • Loading branch information
brokenpip3 authored Feb 19, 2024
2 parents d6e5689 + ef425f2 commit 8a97eb3
Showing 1 changed file with 14 additions and 25 deletions.
39 changes: 14 additions & 25 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8a97eb3

Please sign in to comment.