From 0b7e872c0fae68122070a047094a771de512f882 Mon Sep 17 00:00:00 2001 From: Johannes Schnatterer Date: Wed, 25 Oct 2023 16:39:03 +0200 Subject: [PATCH] Add GH action --- .github/workflows/docker-image.yml | 58 ++++++++++++++++++++++++++++++ .gitignore | 1 + LICENSE | 21 +++++++++++ README.md | 21 +++++++++++ 4 files changed, 101 insertions(+) create mode 100644 .github/workflows/docker-image.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..8003486 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,58 @@ +name: Push image +on: + schedule: + # Rebuild once a week + - cron: '0 0 * * 0' + push: + branches: [ main ] + + # Allow running this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout image repo + uses: actions/checkout@v3 + - name: Checkout upstream repo + uses: actions/checkout@v3 + with: + repository: mailhog/mailhog + token: ${{ secrets.GITHUB_TOKEN }} + path: upstream + # We're only interested in the tags, so check them out, too (not just a single commit) + fetch-depth: 0 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Create tags + id: create-tag + run: | + # Find latest tag + cd upstream + VERSION="$(git describe --tags $(git rev-list --tags --max-count=1))" + VERSION_DATE="$VERSION-$(date +'%Y-%m-%d')" + + GHCR_IMAGE=ghcr.io/${{ github.repository_owner }}/mailhog + TAGS="${GHCR_IMAGE}:latest,${GHCR_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION_DATE}" + echo "TAGS=${TAGS}" | tee -a $GITHUB_ENV + - name: Build and push + id: docker_build + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ env.TAGS }} + labels: | + org.opencontainers.image.authors=${{ github.repository_owner }} + org.opencontainers.image.created=${{ env.BUILD_DATE }} + org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }} + org.opencontainers.image.ref.name=${{ env.GIT_REF }} + org.opencontainers.image.revision=${{ env.GIT_SHA }} + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA}} and ref ${{ env.GIT_REF }} + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e3b2c62 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Cloudogu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3415eb9 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +MailHog [![Docker Build and Push](https://github.com/cloudogu/mailhog-image/actions/workflows/docker-image.yml/badge.svg)](https://github.com/cloudogu/mailhog/actions/workflows/docker-image.yml) +========= + +| :information_source: | This is a fork from upstream [mailhog](https://github.com/mailhog/MailHog) that provides more recent image builds | +|---------------|:------------------------| + +See [mailhog's README](https://github.com/mailhog/MailHog/blob/master/README.md) for more details. + +## Running + +```bash +docker run --rm -d -p 1025:1025 -p 8025:8025 ghcr.io/cloudogu/mailhog +``` +You can send mails via SMTP to localhost:1025 and see mailhogs web UI via localhost:8025 + +## Releasing + +To build and push a fresh image on the latest alpine version and mailhog, just [run GH action](https://github.com/cloudogu/mailhog-image/actions/workflows/docker-image.yml). This sets three tags +* `latest` +* MailHog's latest tag, e.g. `1.0.1` +* MailHog's latest tag + time stamp, e.g. `1.0.1-2023-10-25` \ No newline at end of file