Change tag convention and allow multiple registries (#1763)

* Change tag convention and allow multiple registries

* Add ghcr username secret

* Introduce repository secrets

Again, use-case being forks not having to change these values in the YAML.

* Update image tag according to convention

* Add available sources and tag convention
This commit is contained in:
Frederic Werner 2021-01-24 23:18:37 +01:00 committed by GitHub
parent cb1e6d579e
commit bbd1b36a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 10 deletions

View File

@ -2,7 +2,11 @@ name: "Build, Test & Deploy"
on: on:
push: push:
branches: [ "master", "stable" ] branches:
- master
- stable
tags:
- '*.*.*'
jobs: jobs:
build-and-test-image: build-and-test-image:
@ -52,14 +56,16 @@ jobs:
submodules: recursive submodules: recursive
- name: Prepare tags - name: Prepare tags
id: prep id: prep
run: | uses: crazy-max/ghaction-docker-meta@v1
DOCKER_IMAGE=${{ secrets.DOCKER_REPOSITORY }} with:
VERSION=latest images: |
[[ $GITHUB_REF == refs/tags/* ]] && VERSION=${GITHUB_REF#refs/tags/v} ${{ secrets.DOCKER_REPOSITORY }}
[[ $GITHUB_REF == 'refs/heads/stable' ]] && VERSION=stable ${{ secrets.GHCR_REPOSITORY }}
TAGS="${DOCKER_IMAGE}:${VERSION}" tag-edge: true
[[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && TAGS="$TAGS,${DOCKER_IMAGE}:latest" tag-semver: |
echo ::set-output name=tags::${TAGS} {{major}}
{{major}}.{{minor}}
{{major}}.{{minor}}.{{patch}}
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v1 uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx - name: Set up Docker Buildx
@ -77,6 +83,12 @@ jobs:
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: Build image locally - name: Build image locally
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:

View File

@ -34,7 +34,7 @@ The development workflow is the following:
7. [Commit][commit] and [sign your commit][gpg], push and create a pull-request to merge into `master` 7. [Commit][commit] and [sign your commit][gpg], push and create a pull-request to merge into `master`
1. Pull requests are automatically tested against the CI and will be reviewed when tests pass 1. Pull requests are automatically tested against the CI and will be reviewed when tests pass
2. When your changes are validated, your branch is merged 2. When your changes are validated, your branch is merged
3. CI builds the new `:latest` image 3. CI builds the new `:edge` image immediately and your changes will be includes in the next version release.
## Coding Style ## Coding Style

View File

@ -61,6 +61,21 @@ A fullstack but simple mail server (SMTP, IMAP, LDAP, Antispam, Antivirus, etc.)
## Usage ## Usage
### Available image sources / tags
The [CI/CD workflows](https://github.com/docker-mailserver/docker-mailserver/actions) automatically build, test and push new images to container registries. Currently, the following registries are supported:
- [DockerHub](https://hub.docker.com/repository/docker/mailserver/docker-mailserver)
- [GitHub Container Registry](https://github.com/orgs/docker-mailserver/packages?repo_name=docker-mailserver)
All workflows are using the **tagging convention** listed below. It is subsequently applied to all images pushed to supported container registries:
| Event | Ref | Commit SHA | Image Tags |
|--------------|-----------------------|------------|-------------------------------|
| `push` | `refs/heads/master` | `cf20257` | `edge` |
| `push` | `refs/heads/stable` | `cf20257` | `stable` |
| `push tag` | `refs/tags/1.2.3` | `ad132f5` | `1.2.3`, `1.2`, `1`, `latest` |
| `push tag` | `refs/tags/v1.2.3` | `ad132f5` | `1.2.3`, `1.2`, `1`, `latest` |
### Get the tools ### Get the tools
Download the `docker-compose.yml`, `compose.env`, `mailserver.env` and the `setup.sh` files: Download the `docker-compose.yml`, `compose.env`, `mailserver.env` and the `setup.sh` files: