-
Notifications
You must be signed in to change notification settings - Fork 1
63 lines (54 loc) · 1.81 KB
/
release.yaml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Build and Publish the mailserver Docker Image to GHCR.io
# Manually-triggered action to build the latest version (or optionally, if provided, a release tag)
# of mailserver.
on:
workflow_dispatch:
inputs:
version_tag:
description: Optional version tag to build. Defaults to latest main.
required: false
tag_as_latest:
description: Also tag image as latest (in addition to tag supplied / computed).
type: boolean
default: 0
jobs:
build_and_publish_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: mailserver
fetch-depth: 0
- name: Optionally Check Out Tag
if: ${{ inputs.version_tag }}
# work around https://github.com/actions/runner/issues/665
shell: bash
env:
VERSION_TAG: ${{ inputs.version_tag }}
run: |
cd mailserver
git checkout "mailserver-$VERSION_TAG"
- name: Grok image tag
run: |
cd mailserver
git describe --tags | tee SRC_TAG
echo "ghcr.io/t-lo/mailserver:$(cat SRC_TAG)" | tee IMAGE_TAG
- name: Build the docker image
run: |
cd mailserver
tag=$(cat IMAGE_TAG)
docker build -t "$(cat IMAGE_TAG)" .
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Image
run: |
docker push "$(cat mailserver/IMAGE_TAG)"
- name: Optionally Tag Image as Latest
if: ${{ inputs.tag_as_latest }}
run: |
docker tag "$(cat mailserver/IMAGE_TAG)" ghcr.io/t-lo/mailserver:latest
docker push ghcr.io/t-lo/mailserver:latest