2021-01-16 09:16:05 +00:00
|
|
|
name: "Build, Test & Deploy"
|
|
|
|
|
|
|
|
on:
|
2021-02-18 21:56:13 +00:00
|
|
|
workflow_dispatch:
|
2021-01-16 09:16:05 +00:00
|
|
|
push:
|
2021-01-24 22:18:37 +00:00
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
- stable
|
2021-02-11 08:48:45 +00:00
|
|
|
paths:
|
|
|
|
- 'target/**'
|
|
|
|
- '.dockerignore'
|
|
|
|
- '.gitmodules'
|
|
|
|
- 'Dockerfile'
|
|
|
|
- 'setup.sh'
|
2021-01-24 22:18:37 +00:00
|
|
|
tags:
|
|
|
|
- '*.*.*'
|
2021-01-16 09:16:05 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-01-17 16:41:47 +00:00
|
|
|
build-and-test-image:
|
2021-01-16 14:34:31 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-01-16 09:16:05 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
submodules: recursive
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
id: buildx
|
|
|
|
- name: Cache Docker layers
|
2021-04-19 07:07:30 +00:00
|
|
|
uses: actions/cache@v2.1.5
|
2021-01-16 09:16:05 +00:00
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Build image locally
|
2021-05-12 09:48:11 +00:00
|
|
|
uses: docker/build-push-action@v2.4.0
|
2021-01-16 09:16:05 +00:00
|
|
|
with:
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
|
|
|
build-args: |
|
|
|
|
VCS_REF=${{ github.sha }}
|
|
|
|
VCS_VER=${{ github.ref }}
|
2021-01-17 16:41:47 +00:00
|
|
|
platforms: linux/amd64
|
|
|
|
load: true
|
|
|
|
tags: mailserver-testing:ci
|
2021-01-16 09:16:05 +00:00
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
2021-01-17 16:41:47 +00:00
|
|
|
- name: Run test suite
|
|
|
|
run: >
|
|
|
|
NAME=mailserver-testing:ci
|
|
|
|
bash -c 'make generate-accounts tests'
|
2021-01-16 09:16:05 +00:00
|
|
|
env:
|
|
|
|
CI: true
|
|
|
|
|
2021-01-17 16:41:47 +00:00
|
|
|
build-multiarch-and-publish:
|
|
|
|
needs: build-and-test-image
|
2021-01-16 14:34:31 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-01-16 09:16:05 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
submodules: recursive
|
2021-01-17 16:41:47 +00:00
|
|
|
- name: Prepare tags
|
2021-01-16 09:16:05 +00:00
|
|
|
id: prep
|
2021-05-12 08:52:43 +00:00
|
|
|
uses: docker/metadata-action@v3.1.0
|
2021-01-24 22:18:37 +00:00
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
${{ secrets.DOCKER_REPOSITORY }}
|
|
|
|
${{ secrets.GHCR_REPOSITORY }}
|
2021-04-05 10:20:23 +00:00
|
|
|
tags: |
|
|
|
|
type=edge,branch=master
|
|
|
|
type=semver,pattern={{major}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
|
|
|
flavor: |
|
|
|
|
latest=auto
|
2021-01-16 09:16:05 +00:00
|
|
|
- name: Set up QEMU
|
2021-05-12 08:37:13 +00:00
|
|
|
uses: docker/setup-qemu-action@v1.1.0
|
2021-01-16 09:16:05 +00:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
id: buildx
|
|
|
|
- name: Cache Docker layers
|
2021-04-19 07:07:30 +00:00
|
|
|
uses: actions/cache@v2.1.5
|
2021-01-16 09:16:05 +00:00
|
|
|
with:
|
|
|
|
path: /tmp/.buildx-cache
|
|
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Login to DockerHub
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
2021-01-24 22:18:37 +00:00
|
|
|
- name: Login to GitHub Container Registry
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ secrets.GHCR_USERNAME }}
|
|
|
|
password: ${{ secrets.GHCR_PASSWORD }}
|
2021-01-16 09:16:05 +00:00
|
|
|
- name: Build image locally
|
2021-05-12 09:48:11 +00:00
|
|
|
uses: docker/build-push-action@v2.4.0
|
2021-01-16 09:16:05 +00:00
|
|
|
with:
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
context: .
|
|
|
|
file: ./Dockerfile
|
|
|
|
build-args: |
|
|
|
|
VCS_REF=${{ github.sha }}
|
|
|
|
VCS_VER=${{ github.ref }}
|
|
|
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|