-
Notifications
You must be signed in to change notification settings - Fork 3
61 lines (49 loc) · 1.54 KB
/
Copy pathdocker-publish.yml
File metadata and controls
61 lines (49 loc) · 1.54 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
name: Docker Publish
on:
push:
branches:
- main
- master
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
publish:
name: Publish GHCR images
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v6
- name: Log in to GHCR
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
- name: Build and push images
shell: bash
run: |
set -euo pipefail
owner="${GITHUB_REPOSITORY_OWNER,,}"
server_image="ghcr.io/${owner}/blacknode-server"
editor_image="ghcr.io/${owner}/blacknode-editor"
short_sha="${GITHUB_SHA::12}"
tags=("${short_sha}")
if [[ "${GITHUB_REF_TYPE}" == "branch" ]]; then
tags+=("latest")
fi
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
tags+=("${GITHUB_REF_NAME}")
tags+=("${GITHUB_REF_NAME#v}")
fi
server_args=()
editor_args=()
for tag in "${tags[@]}"; do
server_args+=("-t" "${server_image}:${tag}")
editor_args+=("-t" "${editor_image}:${tag}")
done
docker build -f docker/Dockerfile.server "${server_args[@]}" .
docker build -f docker/Dockerfile.editor "${editor_args[@]}" .
for tag in "${tags[@]}"; do
docker push "${server_image}:${tag}"
docker push "${editor_image}:${tag}"
done