Skip to content

Commit 5f33342

Browse files
committed
build: create services image workflows.
1 parent 9a122d2 commit 5f33342

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build and release services Images
2+
3+
on:
4+
push:
5+
branches:
6+
- release-*
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: "Tag version to be used for Docker image"
13+
required: true
14+
default: "v3.8.3"
15+
16+
jobs:
17+
build-and-push:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v2
26+
27+
- name: Log in to Docker Hub
28+
uses: docker/login-action@v2
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
32+
33+
- name: Log in to GitHub Container Registry
34+
uses: docker/login-action@v2
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.repository_owner }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Log in to Aliyun Container Registry
41+
uses: docker/login-action@v2
42+
with:
43+
registry: registry.cn-hangzhou.aliyuncs.com
44+
username: ${{ secrets.ALIREGISTRY_USERNAME }}
45+
password: ${{ secrets.ALIREGISTRY_TOKEN }}
46+
47+
- name: Extract metadata for Docker (tags, labels)
48+
id: meta
49+
uses: docker/metadata-action@v5
50+
with:
51+
tags: |
52+
type=ref,event=tag
53+
type=schedule
54+
type=ref,event=branch
55+
type=semver,pattern={{version}}
56+
type=semver,pattern=v{{version}}
57+
# type=semver,pattern={{major}}.{{minor}}
58+
type=semver,pattern=release-{{raw}}
59+
type=sha
60+
type=raw,value=${{ github.event.inputs.tag }}
61+
62+
- name: Build and push Docker images
63+
run: |
64+
ROOT_DIR="build/images"
65+
for dir in "$ROOT_DIR"/*/; do
66+
# Find Dockerfile or *.dockerfile in a case-insensitive manner
67+
dockerfile=$(find "$dir" -maxdepth 1 -type f \( -iname 'dockerfile' -o -iname '*.dockerfile' \) | head -n 1)
68+
69+
if [ -n "$dockerfile" ] && [ -f "$dockerfile" ]; then
70+
IMAGE_NAME=$(basename "$dir")
71+
echo "Building Docker image for $IMAGE_NAME with tags:"
72+
73+
# Initialize tag arguments
74+
tag_args=()
75+
76+
# Read each tag and append --tag arguments
77+
while IFS= read -r tag; do
78+
tag_args+=(--tag "${{ secrets.DOCKER_USERNAME }}/$IMAGE_NAME:$tag")
79+
tag_args+=(--tag "ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME:$tag")
80+
tag_args+=(--tag "registry.cn-hangzhou.aliyuncs.com/openimsdk/$IMAGE_NAME:$tag")
81+
done <<< "${{ steps.meta.outputs.tags }}"
82+
83+
# Build and push the Docker image with all tags
84+
docker buildx build --platform linux/amd64,linux/arm64 \
85+
--file "$dockerfile" \
86+
"${tag_args[@]}" \
87+
--push "$dir"
88+
else
89+
echo "No valid Dockerfile found in $dir"
90+
fi
91+
done

0 commit comments

Comments
 (0)