1
1
Fork 0
mirror of https://github.com/docker-mailserver/docker-mailserver synced 2024-05-27 14:46:06 +02:00

feat: leverage cache to prevent unnecessary pushing and building (#14)

* feat: leverage cache to prevent unnecessary pushing and building

* fix: combine test build and test suite to leverage cache

* fix: revert inadvertently changed parts

* fix: review-requested changes

* fix: update test tags to use static ci tag
This commit is contained in:
Nick Pappas 2021-01-17 10:41:47 -06:00 committed by GitHub
parent 061fe12aa7
commit 717aeffae8
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 55 deletions

View File

@ -5,23 +5,13 @@ on:
branches: [ "master", "stable" ]
jobs:
build:
build-and-test-image:
runs-on: ubuntu-20.04
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
@ -32,11 +22,6 @@ jobs:
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:
@ -46,35 +31,26 @@ jobs:
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 }}
platforms: linux/amd64
load: true
tags: mailserver-testing:ci
cache-to: type=local,dest=/tmp/.buildx-cache
test:
needs: build
runs-on: ubuntu-20.04
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'
- name: Run test suite
run: >
NAME=mailserver-testing:ci
bash -c 'make generate-accounts tests'
env:
CI: true
publish:
needs: test
build-multiarch-and-publish:
needs: build-and-test-image
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Prepare
- name: Prepare tags
id: prep
run: |
DOCKER_IMAGE=docker.io/mailserver/docker-mailserver
@ -111,7 +87,6 @@ jobs:
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

View File

@ -6,35 +6,24 @@ jobs:
build-and-test:
runs-on: ubuntu-20.04
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
id: buildx
-
name: Build image locally
- 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 }}
context: .
file: ./Dockerfile
load: true
platforms: linux/amd64
tags: docker.io/mailserver/testing:ci
-
name: Run all tests
load: true
tags: mailserver-testing:ci
- name: Run test suite
run: >
NAME=docker.io/mailserver/testing:ci
NAME=mailserver-testing:ci
bash -c 'make generate-accounts tests'
env:
CI: true