diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 2b941e43..2ef8d152 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -7,6 +7,10 @@ on: version: required: true type: string + platforms: + required: false + type: string + default: "linux/amd64,linux/arm64" working-dir: required: true type: string @@ -24,28 +28,32 @@ jobs: steps: - name: ⬇️ Checkout uses: actions/checkout@v2 - - name: Download artifact + - name: 📦 Download artifact uses: actions/download-artifact@v2 if: inputs.artifact-name && inputs.artifact-path with: name: ${{ inputs.artifact-name }} path: ${{ inputs.artifact-path }} + - name: 🦤 Set up qemu + uses: docker/setup-qemu-action@v1 + - name: 🐳 Set up docker buildx + uses: docker/setup-buildx-action@v1 - name: 🧰 Build container image + if: github.ref != 'refs/heads/main' || inputs.version == 'dev' working-directory: ${{ inputs.working-dir }} - run: | - docker build \ - -t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:latest" \ - -t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:$(git rev-parse --short HEAD)" \ - -t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:${{ inputs.version }}" . + run: docker buildx build --platform "${{ inputs.platforms }}" . - name: 🔑 Login to GitHub Container registry + if: github.ref == 'refs/heads/main' && inputs.version != 'dev' uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: ⬆️ Push container image + - name: 🧰 ⬆️ Build and push container image if: github.ref == 'refs/heads/main' && inputs.version != 'dev' + working-directory: ${{ inputs.working-dir }} run: | - docker push "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:latest" - docker push "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:$(git rev-parse --short HEAD)" - docker push "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:${{ inputs.version }}" + docker buildx build --push --platform "${{ inputs.platforms }}" \ + -t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:latest" \ + -t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:$(git rev-parse --short HEAD)" \ + -t "ghcr.io/codecentric/habitcentric/${{ inputs.image-name }}:${{ inputs.version }}" .