Skip to content

Commit

Permalink
Add multiarch image build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
macropin committed Aug 1, 2022
1 parent ae99286 commit d266833
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/dockerhub-build-push-multi-arch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Source: https://github.com/panubo/reference-github-actions/blob/main/dockerhub-build-push-multi-arch.yml
# Description: Multi arch build and push to Docker Hub
# LICENSE: MIT License, Copyright (c) 2022 Volt Grid Pty Ltd t/a Panubo

# - Multi arch build, amd64 and arm64
# - Uses docker/metadata-action to generate image tags
# - Push to dockerhub

name: Docker Hub Build and Push (Multi-arch)

env:
REPO_NAME: docker.io/panubo/sshd

on:
push:
branches:
- main
tags:
- 'v*'

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
# list of Docker images to use as base name for tags
images: |
${{ env.REPO_NAME }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.PANUBUILD_DOCKERHUB_USERNAME }}
password: ${{ secrets.PANUBUILD_DOCKERHUB_TOKEN }}

- name: Build and Push
uses: docker/build-push-action@v3
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: Dockerfile
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit d266833

Please sign in to comment.