-
Notifications
You must be signed in to change notification settings - Fork 1
50 lines (46 loc) · 1.95 KB
/
docker-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download latest MailHog release
run: |
# Find latest release
VERSION="$( curl -s -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/mailhog/mailhog/releases/latest" | jq -r '.tag_name')"
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
echo "VERSION=${VERSION}" | tee -a $GITHUB_ENV
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
build-args: VERSION=${{ env.VERSION }}
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 }}