Skip to content

1.4.0

1.4.0 #69

name: Build multi-arch Docker Image
permissions:
contents: read
packages: write
on:
release:
types: [published]
push:
branches: [main]
pull_request:
env:
IMAGE_REPOSITORY: testcontainers/sshd
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Login to Docker Hub
# Only if we need to push an image
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to Github Container Registry
# Only if we need to push an image
if: ${{ github.event_name == 'release' && github.event.action == 'published' }}
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Setup for buildx
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
# Debugging information
- name: Docker info
run: docker info
- name: Buildx inspect
run: docker buildx inspect
# Build and (optionally) push the image
- name: Build image
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
# Only push if we are publishing a release
push: ${{ github.event_name == 'release' && github.event.action == 'published' }}
# Use a 'temp' tag, that won't be pushed, for non-release builds
tags: |
${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name || 'temp' }}
ghcr.io/${{ env.IMAGE_REPOSITORY }}:${{ github.event.release.tag_name || 'temp' }}