Skip to content

Commit

Permalink
chore(ci): Publish images based on the next branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jeboehm committed Jun 8, 2022
1 parent d533d37 commit 726eeb7
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
18 changes: 15 additions & 3 deletions .ci/bin/push_image_version.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
#!/bin/sh

VERSION="${1}"
COMPONENTS="mda mta db filter ssl virus web"

if [ "${VERSION}" = "" ]
then
echo "Expected version string!"

exit 1
fi

for component in $COMPONENTS
do
docker tag jeboehm/mailserver-$component:latest jeboehm/mailserver-$component:$1
docker tag jeboehm/mailserver-$component:latest jeboehm/mailserver-$component:${VERSION}

if [ "${VERSION}" != "next" ]
then
docker push jeboehm/mailserver-$component:latest
fi

docker push jeboehm/mailserver-$component:latest
docker push jeboehm/mailserver-$component:$1
docker push jeboehm/mailserver-$component:${VERSION}
done
17 changes: 11 additions & 6 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,34 @@ on:
pull_request:

jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
runs-on: ubuntu-latest

strategy:
matrix:
BUILD_CASE: [virus_disabled, virus_enabled, relayhost, fts_disabled]
BUILD_CASE:
- virus_disabled
- virus_enabled
- relayhost
- fts_disabled

steps:
- uses: actions/checkout@v3

- name: Prepare environment
run: |
cp .env.dist .env
make .env
cat .ci/matrix/${{ matrix.BUILD_CASE }}.env >> .env
- name: Build images
run: make build

- name: Run tests
run: |
if [ -x ".ci/matrix/${{ matrix.BUILD_CASE }}/test.sh" ]; then
.ci/matrix/${{ matrix.BUILD_CASE }}/test.sh
fi
make ci
make test
- name: Collect logs
if: failure()
Expand Down
25 changes: 17 additions & 8 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,48 @@ on:
push:
branches:
- main
- next

jobs:
bump_version:
publish_release:
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v3

- name: Prepare environment
run: make .env

- name: Build images
run: make build

- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
if: github.ref == 'refs/heads/main'

- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
if: github.ref == 'refs/heads/main'

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Prepare environment
- name: Push images (new tag)
run: |
cp .env.dist .env
.ci/bin/push_image_version.sh ${{ steps.tag_version.outputs.new_tag }}
if: github.ref == 'refs/heads/main'

- name: Build and push images
- name: Push images (next)
run: |
make build
.ci/bin/push_image_version.sh ${{ steps.tag_version.outputs.new_tag }}
.ci/bin/push_image_version.sh next
if: github.ref == 'refs/heads/next'
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
COMPOSE_PRODUCTION = bin/production.sh
COMPOSE_TEST = bin/test.sh

.PHONY: ci
ci: test

.PHONY: prod
prod: up

Expand All @@ -16,7 +13,7 @@ pull:
$(COMPOSE_PRODUCTION) pull

.PHONY: test
test: .env build up fixtures
test: up fixtures
$(COMPOSE_TEST) run --rm test

.PHONY: clean
Expand Down

0 comments on commit 726eeb7

Please sign in to comment.