103 lines
3.3 KiB
YAML
103 lines
3.3 KiB
YAML
name: Publish Docker image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
# - main
|
|
- release-*
|
|
# tags:
|
|
# - v*
|
|
release:
|
|
types: [published]
|
|
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Tag version to be used for Docker image"
|
|
required: true
|
|
default: "v3.8.0"
|
|
|
|
env:
|
|
GO_VERSION: "1.22"
|
|
|
|
jobs:
|
|
build-image:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3.8.0
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3.3.0
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
uses: docker/login-action@v3.3.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Log in to Aliyun Container Registry
|
|
uses: docker/login-action@v3.3.0
|
|
with:
|
|
registry: registry.cn-hangzhou.aliyuncs.com
|
|
username: ${{ secrets.ALIREGISTRY_USERNAME }}
|
|
password: ${{ secrets.ALIREGISTRY_TOKEN }}
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5.6.0
|
|
with:
|
|
images: |
|
|
openim/openim-chat
|
|
ghcr.io/openimsdk/openim-chat
|
|
registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat
|
|
tags: |
|
|
type=ref,event=tag
|
|
type=schedule
|
|
type=ref,event=branch
|
|
# type=ref,event=pr
|
|
# type=semver,pattern={{version}}
|
|
type=semver,pattern=v{{version}}
|
|
type=semver,pattern=release-{{raw}}
|
|
type=sha
|
|
type=raw,value=${{ github.event.inputs.tag }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
- name: Verify multi-platform support
|
|
run: |
|
|
images=("openim/openim-chat" "ghcr.io/openimsdk/openim-chat" "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat")
|
|
for image in "${images[@]}"; do
|
|
for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr ',' '\n'); do
|
|
manifest=$(docker manifest inspect "$image:$tag" || echo "error")
|
|
if [[ "$manifest" == "error" ]]; then
|
|
echo "Manifest not found for $image:$tag"
|
|
exit 1
|
|
fi
|
|
amd64_found=$(echo "$manifest" | jq '.manifests[] | select(.platform.architecture == "amd64")')
|
|
arm64_found=$(echo "$manifest" | jq '.manifests[] | select(.platform.architecture == "arm64")')
|
|
if [[ -z "$amd64_found" ]]; then
|
|
echo "Multi-platform support check failed for $image:$tag - missing amd64"
|
|
exit 1
|
|
fi
|
|
if [[ -z "$arm64_found" ]]; then
|
|
echo "Multi-platform support check failed for $image:$tag - missing arm64"
|
|
exit 1
|
|
fi
|
|
done
|
|
done
|