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:
push:
branches: [ "master", "stable" ]
branches:
- master
- stable
tags:
- '*.*.*'
jobs:
build-and-test-image:
@ -52,14 +56,16 @@ jobs:
submodules: recursive
- name: Prepare tags
id: prep
run: |
DOCKER_IMAGE=${{ secrets.DOCKER_REPOSITORY }}
VERSION=latest
[[ $GITHUB_REF == refs/tags/* ]] && VERSION=${GITHUB_REF#refs/tags/v}
[[ $GITHUB_REF == 'refs/heads/stable' ]] && VERSION=stable
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}
uses: crazy-max/ghaction-docker-meta@v1
with:
images: |
${{ secrets.DOCKER_REPOSITORY }}
${{ secrets.GHCR_REPOSITORY }}
tag-edge: true
tag-semver: |
{{major}}
{{major}}.{{minor}}
{{major}}.{{minor}}.{{patch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
@ -77,6 +83,12 @@ jobs:
with:
username: ${{ secrets.DOCKER_USERNAME }}
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
uses: docker/build-push-action@v2
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`
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
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

View file

@ -61,6 +61,21 @@ A fullstack but simple mail server (SMTP, IMAP, LDAP, Antispam, Antivirus, etc.)
## 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
Download the `docker-compose.yml`, `compose.env`, `mailserver.env` and the `setup.sh` files: