forked from target/strelka
-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (48 loc) · 1.72 KB
/
publish_latest.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
name: Publish Latest Images to Docker Hub
on:
create:
tags:
- '*'
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-22.04
steps:
- name: Clone Action Repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to Docker Hub
uses: docker/login-action@v2.1.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build, Tag and Push Images
run: |
# Stop the script on errors
set -e
# Enable Docker BuildKit
export DOCKER_BUILDKIT=1
# Set tag variables
COMMIT_HASH=$(git rev-parse --short HEAD)
TAG_NAME=$(git describe --tags --abbrev=0)
# Define a dictionary with paths to Dockerfiles as keys and image names as values
declare -A images
images=(
["build/python/backend"]="target/strelka-backend"
["build/go/frontend"]="target/strelka-frontend"
["build/go/fileshot"]="target/strelka-fileshot"
["build/go/filestream"]="target/strelka-filestream"
["build/go/oneshot"]="target/strelka-oneshot"
["build/go/manager"]="target/strelka-manager"
)
# Build, tag, and push each image
for path in "${!images[@]}"; do
IMAGE_NAME=${images[$path]}
docker build -f "${path}/Dockerfile" -t "${IMAGE_NAME}:${TAG_NAME}" -t "${IMAGE_NAME}:latest" .
docker push "${IMAGE_NAME}:${TAG_NAME}"
docker push "${IMAGE_NAME}:latest"
done
- name: Logout from Docker Hub
run: docker logout