-
Notifications
You must be signed in to change notification settings - Fork 87
77 lines (74 loc) · 2.26 KB
/
docker.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Docker
on: [push, pull_request]
# push:
# branches:
# - master
# - 'v[0-9]+*'
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Build Image
run: ./script/build.sh latest
publish:
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/v'))
name: Publish
needs: [ build ]
runs-on: ubuntu-latest
steps:
-
name: Check Branch
id: check-branch
run: |
if [[ ${{ github.ref }} =~ ^refs/heads/(master|v[0-9]+\.[0-9]+.*)$ ]]; then
echo ::set-output name=match::true
fi # See: https://stackoverflow.com/a/58869470/1123955
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
-
# https://github.com/docker/setup-buildx-action
name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
version: latest
-
name: Builder instance name
run: echo ${{ steps.buildx.outputs.name }}
-
name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
-
name: Login to DockerHub Registry
run: echo ${{ secrets.DOCKER_PERSONAL_ACCESS_TOKEN }} | docker login -u zixia --password-stdin
env:
DOCKER_PERSONAL_ACCESS_TOKEN: ${{ secrets.DOCKER_PERSONAL_ACCESS_TOKEN }}
-
name: Checkout
uses: actions/checkout@v2
-
name: Is A Publish Branch
if: steps.check-branch.outputs.match == 'true'
run: |
version=$(cat VERSION)
majorVer=$(echo "$version" | cut -d. -f1)
minorVer=$(echo "$version" | cut -d. -f2)
tag="${majorVer}.${minorVer}"
docker build \
--platform linux/386,linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 \
--tag zixia/simple-mail-forwarder:"$tag" \
--tag zixia/simple-mail-forwarder:latest \
--push \
.
-
name: Is Not A Publish Branch
if: steps.check-branch.outputs.match != 'true'
run: echo 'Not A Publish Branch'