2021-01-16 09:16:05 +00:00
|
|
|
name: "Build, Test & Deploy"
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ "master", "stable" ]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
2021-01-16 14:34:31 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-01-16 09:16:05 +00:00
|
|
|
outputs:
|
|
|
|
imagetag: ${{ steps.prep.outputs.imagetag }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
submodules: recursive
|
|
|
|
- name: Prepare
|
|
|
|
id: prep
|
|
|
|
run: |
|
|
|
|
DOCKER_IMAGE=docker.io/mailserver/testing
|
|
|
|
TAGS="${DOCKER_IMAGE}:${GITHUB_SHA::8},${DOCKER_IMAGE}:latest"
|
|
|
|
echo ::set-output name=tags::${TAGS}
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
id: buildx
|
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
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 }}
|
|
|
|
- name: Build image locally
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
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
|
|
|
|
pull: true
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
|
|
|
|
|
|
|
test:
|
|
|
|
needs: build
|
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: run test suite
|
|
|
|
run: |
|
|
|
|
NAME=docker.io/mailserver/testing:${GITHUB_SHA::8} bash -c 'make generate-accounts tests'
|
|
|
|
env:
|
|
|
|
CI: true
|
|
|
|
|
|
|
|
publish:
|
|
|
|
needs: test
|
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: Prepare
|
|
|
|
id: prep
|
|
|
|
run: |
|
|
|
|
DOCKER_IMAGE=docker.io/mailserver/docker-mailserver
|
|
|
|
VERSION=latest
|
|
|
|
[[ $GITHUB_REF == refs/tags/* ]] && VERSION=${GITHUB_REF#refs/tags/v}
|
2021-01-16 11:06:40 +00:00
|
|
|
[[ $GITHUB_REF == 'refs/heads/stable' ]] && VERSION=stable
|
2021-01-16 09:16:05 +00:00
|
|
|
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
|
|
|
[[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && TAGS="$TAGS,${DOCKER_IMAGE}:latest"
|
|
|
|
echo ::set-output name=tags::${TAGS}
|
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
id: buildx
|
|
|
|
- name: Cache Docker layers
|
|
|
|
uses: actions/cache@v2
|
|
|
|
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 }}
|
|
|
|
- name: Build image locally
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
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
|
|
|
|
pull: true
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|