Skip to content

Commit

Permalink
Generalize Docker image build pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
laurivosandi authored and andris9 committed May 3, 2023
1 parent 8eb1aa3 commit f31549a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build and publish a Docker image for master branch
on:
push:
branches:
- master
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64,arm'

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/arm64,linux/amd64,linux/arm/v7

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: ${{ steps.buildx.outputs.platforms }}
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:latest
20 changes: 7 additions & 13 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Build and publish a Docker image to Docker hub and ghcr.io
on:
push:
branches:
- master
- docker
tags:
- 'v*.*.*'

Expand All @@ -13,40 +10,37 @@ jobs:
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: |
nodemailer/wildduck
ghcr.io/nodemailer/wildduck
# generate Docker tags based on the following events/attributes
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'amd64,arm64,arm'
platforms: 'arm64,arm'

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/arm64,linux/amd64,linux/arm/v7

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand All @@ -57,7 +51,7 @@ jobs:
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/arm64,linux/amd64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
platforms: ${{ steps.buildx.outputs.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit f31549a

Please sign in to comment.