Skip to content

Commit

Permalink
feat: improve publish docker image workflows (#2697)
Browse files Browse the repository at this point in the history
* refactor: add GetAdminToken interface.

* update config.

* update workflows logic.

* feat: improve publish docker image workflows

* update condition logic.
  • Loading branch information
mo3et authored Oct 8, 2024
1 parent da040b1 commit 93f6c92
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
42 changes: 32 additions & 10 deletions .github/workflows/publish-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- release-*
# tags:
# - 'v*'

release:
types: [published]
Expand All @@ -15,11 +17,8 @@ on:
required: true
default: "v3.8.0"

# env:
# GO_VERSION: "1.21"

jobs:
publish-docker-images:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -28,16 +27,22 @@ jobs:

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push Docker image
- name: Build Docker image
id: build
uses: docker/build-push-action@v5
with:
context: ./main-repo
load: true
tags: "openim/openim-server:local"
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Save Docker image to file
run: docker save -o image.tar openim/openim-server:local

- name: Checkout compose repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -92,9 +97,25 @@ jobs:
# exit 0
# fi

publish-docker-images:
runs-on: ubuntu-latest
needs: build-and-test
if: success()
steps:
- uses: actions/checkout@v4
with:
path: main-repo

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Load Docker image from file
run: docker load -i image.tar

- name: Extract metadata for Docker # (tags, labels)
if: success()
- name: Extract metadata for Docker (tags, labels)
id: meta
uses: docker/[email protected]
with:
Expand All @@ -108,12 +129,13 @@ jobs:
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={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=release-{{raw}}
type=sha
type=raw,value=${{ github.event.inputs.tag }}
- name: Log in to Docker Hub
uses: docker/login-action@v2
Expand All @@ -135,7 +157,7 @@ jobs:
username: ${{ secrets.ALIREGISTRY_USERNAME }}
password: ${{ secrets.ALIREGISTRY_TOKEN }}

- name: Build and push Docker images
- name: Push Docker images
uses: docker/build-push-action@v5
with:
context: ./main-repo
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use Go 1.21 Alpine as the base image for building the application
FROM golang:1.21-alpine as builder
FROM golang:1.21-alpine AS builder

# Define the base directory for the application as an environment variable
ENV SERVER_DIR=/openim-server
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/group/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ func (g *groupServer) GetSpecifiedUserGroupRequestInfo(ctx context.Context, req
}

adminIDs = append(adminIDs, owners[0].UserID)
adminIDs = append(adminIDs, g.config.Share.IMAdminUserID...)

if !datautil.Contain(req.UserID, adminIDs...) {
return nil, errs.ErrNoPermission.WrapMsg("opUser no permission")
Expand Down

0 comments on commit 93f6c92

Please sign in to comment.