Skip to content

Commit

Permalink
Merge pull request #7 from controllan/feature/allow-multi-platform-bu…
Browse files Browse the repository at this point in the history
…ilds

ci(build): build each image on the specific os and push the images separately.
  • Loading branch information
pat-git authored Sep 8, 2024
2 parents deb8dcb + 6aec9fb commit a11c397
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
dry_run:
type: boolean
default: false
description: "Parameter to enable a dry-run (run without changes)"
description: "enable dry run"
required: false
tags:
type: string
Expand All @@ -29,12 +29,23 @@ on:
default: ""
description: "The list of labels to be added to the image"
required: false
force_docker_push:
type: boolean
default: false
description: "force docker push"
required: false

run-name: "Build docker image [dry_run=${{ inputs.dry_run }}, ${{ vars.CONTAINER_REGISTRY_URL }}/${{ vars.CONTAINER_REGISTRY_REPOSITORY }}]"

jobs:
build:
strategy:
matrix:
os: [ arm64, amd64 ]
include:
- os: "amd64"
image_suffix: ""
- os: "arm64"
image_suffix: "-arm64"
runs-on: [ self-hosted, ubuntu-latest, '${{ matrix.os }}' ]
name: "Build docker image for ${{ matrix.os }} [dry_run=${{ inputs.dry_run }}, ${{ vars.CONTAINER_REGISTRY_URL }}/${{ vars.CONTAINER_REGISTRY_REPOSITORY }}]"
permissions:
Expand Down Expand Up @@ -71,7 +82,7 @@ jobs:
uses: docker/build-push-action@v6.7.0
with:
context: .
platforms: linux/${{ matrix.os }}
push: ${{ github.event_name != 'pull_request' && inputs.dry_run == false }}
tags: ${{ steps.meta.outputs.tags || inputs.tags }}
platforms: 'linux/${{ matrix.os }}'
push: ${{ (github.event_name != 'pull_request' || inputs.force_docker_push) && inputs.dry_run == false }}
tags: '${{ steps.meta.outputs.tags || inputs.tags }}${{ matrix.image_suffix }}'
labels: ${{ steps.meta.outputs.labels || inputs.labels }}

0 comments on commit a11c397

Please sign in to comment.