fix: docker images (#101) #60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright © 2023 OpenIM open source community. All rights reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: OpenIM Buildx Docker Images | |
on: | |
push: | |
branches: | |
- main | |
- release-* | |
tags: | |
- v* | |
workflow_dispatch: | |
env: | |
IMAGE_NAME: openim-chat | |
# Common versions | |
GO_VERSION: "1.20" | |
DEFAULT_OWNER: "OpenIMSDK" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
# strategy: | |
# matrix: | |
# bin: | |
# - openim-chat | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v3 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
openim/${{env.IMAGE_NAME}} | |
registry.cn-hangzhou.aliyuncs.com/${{github.repository_owner}}/${{env.IMAGE_NAME}} | |
ghcr.io/${{github.repository_owner}}/${{env.IMAGE_NAME}} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Log in to AliYun Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
registry: registry.cn-hangzhou.aliyuncs.com | |
username: ${{ secrets.ALIREGISTRY_USERNAME }} | |
password: ${{ secrets.ALIREGISTRY_TOKEN }} | |
- name: Build and release Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
# platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }},latest | |
push: ${{ github.event_name != 'pull_request' }} |