-
Notifications
You must be signed in to change notification settings - Fork 7
184 lines (164 loc) · 6.09 KB
/
deploy-docker.ui.yaml
File metadata and controls
184 lines (164 loc) · 6.09 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Deploy - Docker (UI)
on:
push:
branches:
- master
tags:
- 'v*.*.*'
env:
GHCR_REPO: ghcr.io/${{ github.repository }}-ui
DOCKERFILE: Dockerfile.ui
jobs:
meta:
name: Compute tags and build info
runs-on: ubuntu-latest
outputs:
sha_short: ${{ steps.vars.outputs.sha_short }}
tag_prefix: ${{ steps.vars.outputs.tag_prefix }}
additional_tags: ${{ steps.vars.outputs.additional_tags }}
app_version: ${{ steps.vars.outputs.app_version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- id: vars
run: |
SHA_SHORT=$(git rev-parse --short HEAD)
echo "sha_short=$SHA_SHORT" >> $GITHUB_OUTPUT
if [[ "${{ github.ref }}" == refs/tags/v*.*.* ]]; then
VERSION_TAG="${GITHUB_REF#refs/tags/}"
echo "tag_prefix=$VERSION_TAG" >> $GITHUB_OUTPUT
echo "additional_tags=[\"$VERSION_TAG\",\"latest\"]" >> $GITHUB_OUTPUT
else
echo "tag_prefix=master" >> $GITHUB_OUTPUT
echo "additional_tags=[\"master\",\"master-latest\"]" >> $GITHUB_OUTPUT
fi
APP_VERSION=$(git describe --tags --always 2>/dev/null || git rev-parse --short HEAD)
echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT
build_amd64:
name: Build amd64 image
needs: meta
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Log in to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build amd64 docker image
env:
PREFIX: ${{ needs.meta.outputs.tag_prefix }}
SHA: ${{ needs.meta.outputs.sha_short }}
APP_VERSION: ${{ needs.meta.outputs.app_version }}
run: |
docker build . --file "$DOCKERFILE" \
--tag "${GHCR_REPO}:${PREFIX}-amd64" \
--tag "${GHCR_REPO}:${PREFIX}-${SHA}-amd64" \
--platform=linux/amd64 \
--build-arg APP_VERSION="$APP_VERSION"
- name: Push amd64 docker images
env:
PREFIX: ${{ needs.meta.outputs.tag_prefix }}
SHA: ${{ needs.meta.outputs.sha_short }}
run: |
docker push "${GHCR_REPO}:${PREFIX}-amd64"
docker push "${GHCR_REPO}:${PREFIX}-${SHA}-amd64"
build_arm64:
name: Build arm64 image
needs: meta
runs-on: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Log in to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build arm64 docker image
env:
PREFIX: ${{ needs.meta.outputs.tag_prefix }}
SHA: ${{ needs.meta.outputs.sha_short }}
APP_VERSION: ${{ needs.meta.outputs.app_version }}
run: |
docker build . --file "$DOCKERFILE" \
--tag "${GHCR_REPO}:${PREFIX}-arm64" \
--tag "${GHCR_REPO}:${PREFIX}-${SHA}-arm64" \
--platform=linux/arm64 \
--build-arg APP_VERSION="$APP_VERSION"
- name: Push arm64 docker images
env:
PREFIX: ${{ needs.meta.outputs.tag_prefix }}
SHA: ${{ needs.meta.outputs.sha_short }}
run: |
docker push "${GHCR_REPO}:${PREFIX}-arm64"
docker push "${GHCR_REPO}:${PREFIX}-${SHA}-arm64"
manifest_sha:
name: Multi-arch sha manifest
needs: [meta, build_amd64, build_arm64]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Log in to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-arch sha manifest
env:
PREFIX: ${{ needs.meta.outputs.tag_prefix }}
SHA: ${{ needs.meta.outputs.sha_short }}
run: |
docker buildx imagetools create -t "${GHCR_REPO}:${PREFIX}-${SHA}" \
"${GHCR_REPO}:${PREFIX}-${SHA}-amd64" \
"${GHCR_REPO}:${PREFIX}-${SHA}-arm64"
manifest_extra:
name: Multi-arch additional manifests
needs: [meta, build_amd64, build_arm64]
if: ${{ needs.meta.outputs.additional_tags != '' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
tag: ${{ fromJSON(needs.meta.outputs.additional_tags) }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
- name: Log in to GHCR
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-arch manifest ${{ matrix.tag }}
env:
PREFIX: ${{ needs.meta.outputs.tag_prefix }}
SHA: ${{ needs.meta.outputs.sha_short }}
TAG: ${{ matrix.tag }}
run: |
docker buildx imagetools create -t "${GHCR_REPO}:${TAG}" \
"${GHCR_REPO}:${PREFIX}-${SHA}-amd64" \
"${GHCR_REPO}:${PREFIX}-${SHA}-arm64"