-
Notifications
You must be signed in to change notification settings - Fork 28
112 lines (103 loc) · 4.13 KB
/
docker_publish.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Publish Docker image
on:
workflow_dispatch:
inputs:
mage_version:
type: string
description: "Mage version built into this image (format: X.Y.Z)"
required: true
memgraph_version:
type: string
description: "Memgraph version built into this image (format: X.Y.Z)"
required: true
shorten_tag:
type: boolean
description: "Make the final tag as short as possible, shortest format is X.Y-memgraph-X.Y"
default: true
additional_tag:
type: choice
default: 'latest'
descritpion: "Additional tag for the image"
required: true
options:
- 'latest'
- 'fix'
force_release:
type: boolean
description: "Overwrite existing image on dockerhub"
default: true
jobs:
build_and_release_docker:
name: Build & release Docker image with tag
runs-on: ubuntu-latest
env:
DOCKER_ORGANIZATION_NAME: memgraph
DOCKER_REPOSITORY_NAME: memgraph-mage
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set image version tag
run: |
MEMGRAPH_VERSION=${{ github.event.inputs.memgraph_version }}
MAGE_VERSION=${{ github.event.inputs.mage_version }}
if [[ ${{ github.event.inputs.shorten_tag }} == true ]]; then
memgraph_patch_version=${MEMGRAPH_VERSION##*.}
mage_patch_version=${MAGE_VERSION##*.}
if [[ "$memgraph_patch_version" -eq 0 ]]; then
MEMGRAPH_VERSION=${MEMGRAPH_VERSION%.*}
fi
if [[ "$mage_patch_version" -eq 0 ]]; then
MAGE_VERSION=${MAGE_VERSION%.*}
fi
fi
echo "VERSION_TAG=$MAGE_VERSION-memgraph-$MEMGRAPH_VERSION" >> $GITHUB_ENV
- name: Check if specified version tag is already pushed
run: |
EXISTS=$(docker manifest inspect $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.VERSION_TAG }} > /dev/null; echo $?)
echo $EXISTS
if [[ ${EXISTS} -eq 0 ]]; then
echo The specified version has been already released to DockerHub!
if [[ ${{ github.event.inputs.force_release }} = true ]]; then
echo Forcing the release
else
echo Stopping the release
exit 1
fi
else
echo All good the specified version has not been release to DockerHub
fi
- name: Download memgraph binary
run: |
curl -L https://download.memgraph.com/memgraph/v${{ github.event.inputs.memgraph_version }}/debian-11/memgraph_${{ github.event.inputs.memgraph_version }}-1_amd64.deb > memgraph-amd64.deb
curl -L https://download.memgraph.com/memgraph/v${{ github.event.inputs.memgraph_version }}/debian-11-aarch64/memgraph_${{ github.event.inputs.memgraph_version }}-1_arm64.deb > memgraph-arm64.deb
- name: Build & push prod docker images
run: |
docker buildx build \
--target prod \
--platform linux/amd64,linux/arm64 \
--tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.VERSION_TAG }} \
--tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ github.event.inputs.additional_tag }} \
--file Dockerfile.release \
--push .
- name: Build & push dev docker images
run: |
docker buildx build \
--target dev \
--platform linux/amd64,linux/arm64 \
--tag $DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ env.VERSION_TAG }}-dev \
--file Dockerfile.release \
--push .