Compare commits

..

2 Commits

Author SHA1 Message Date
Xinwei Xiong(cubxxw-openim) af46d5cbf3 docs: add readme docs
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-07-27 14:51:58 +08:00
Xinwei Xiong(cubxxw-openim) 44cd181834 feat: config env optimize
Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com>
2023-07-27 14:37:02 +08:00
3 changed files with 49 additions and 73 deletions
+7 -31
View File
@@ -29,31 +29,30 @@ jobs:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@v3
# docker.io/openim/openim-server:latest
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker - name: Extract metadata (tags, labels) for Docker
id: meta id: meta
uses: docker/metadata-action@v4.6.0 uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with: with:
images: openim/openim-server images: openim/openim-server
tags: latest tags: latest
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v4 uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with: with:
context: . context: .
push: true push: true
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
# registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server:latest
- name: Log in to AliYun Docker Hub - name: Log in to AliYun Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with: with:
registry: registry.cn-hangzhou.aliyuncs.com registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIREGISTRY_USERNAME }} username: ${{ secrets.ALIREGISTRY_USERNAME }}
@@ -61,42 +60,19 @@ jobs:
- name: Extract metadata (tags, labels) for Docker - name: Extract metadata (tags, labels) for Docker
id: meta2 id: meta2
uses: docker/metadata-action@v4.6.0 uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with: with:
images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server images: registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-server
tags: latest tags: latest
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v4 uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with: with:
context: . context: .
push: true push: true
tags: ${{ steps.meta2.outputs.tags }} tags: ${{ steps.meta2.outputs.tags }}
labels: ${{ steps.meta2.outputs.labels }} labels: ${{ steps.meta2.outputs.labels }}
# ghcr.io/openim/openim-server:latest
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta3
uses: docker/metadata-action@v4.6.0
with:
images: openim/openim-server
tags: latest
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta3.outputs.tags }}
labels: ${{ steps.meta3.outputs.labels }}
# name: OpenIM Build Docker Images # name: OpenIM Build Docker Images
# on: # on:
# push: # push:
+41 -39
View File
@@ -12,46 +12,48 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
name: OpenIM Deploy for dev name: deploy for dev
on: on:
push: push:
branches: branches:
- 'devops' # Only for the dev branch - 'devops' # Only for the dev branch
paths: paths:
- '.github/workflows/*' - '.github/workflows/*'
# - '__test__/**' # dev No immediate testing is required # - '__test__/**' # dev No immediate testing is required
- 'src/**' - 'src/**'
- 'Dockerfile' - 'Dockerfile'
- 'docker-compose.yml' - 'docker-compose.yml'
- 'bin/*' - 'bin/*'
jobs: jobs:
deploy-dev: deploy-dev:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 steps:
- name: set ssh key # Temporarily set up ssh key - uses: actions/checkout@v2
run: | - name: set ssh key # Temporarily set up ssh key
mkdir -p ~/.ssh/ run: |
# secrets.WFP_ID_RSA set in GitHub mkdir -p ~/.ssh/
echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa # secrets.WFP_ID_RSA set in GitHub
chmod 600 ~/.ssh/id_rsa echo "${{secrets.WFP_ID_RSA}}" > ~/.ssh/id_rsa
ssh-keyscan "182.92.xxx.xxx" >> ~/.ssh/known_hosts chmod 600 ~/.ssh/id_rsa
- name: deploy # Deployment ssh-keyscan "182.92.xxx.xxx" >> ~/.ssh/known_hosts
run: | - name: deploy # Deployment
ssh work@182.92.xxx.xxx " run: |
# 【Attention】Log in with the 'work' account, manually create /home/work/imooc-lego directory ssh work@182.92.xxx.xxx "
# Then git clone https://username:password@github.com/imooc-lego/biz-editor-server.git -b dev (private repository, use GitHub username and password) # 【Attention】Log in with the 'work' account, manually create /home/work/imooc-lego directory
# Remember to delete origin to avoid exposing GitHub password # Then git clone https://username:password@github.com/imooc-lego/biz-editor-server.git -b dev (private repository, use GitHub username and password)
cd /home/work/imooc-lego/biz-editor-server; # Remember to delete origin to avoid exposing GitHub password
git remote add origin https://openimbot:${{secrets.WFP_PASSWORD}}@github.com/OpenIMSDK/open-im-server.git;
git checkout dev; cd /home/work/imooc-lego/biz-editor-server;
git pull origin dev; # Download the latest code again git remote add origin https://openimbot:${{secrets.WFP_PASSWORD}}@github.com/OpenIMSDK/open-im-server.git;
git remote remove origin; # Remove origin to avoid exposing GitHub password git checkout dev;
# Start docker git pull origin dev; # Download the latest code again
docker-compose build editor-server; # Same as the service name in docker-compose.yml git remote remove origin; # Remove origin to avoid exposing GitHub password
docker-compose up -d; # Start docker
" docker-compose build editor-server; # Same as the service name in docker-compose.yml
- name: delete ssh key # Delete ssh key docker-compose up -d;
run: rm -rf ~/.ssh/id_rsa "
- name: delete ssh key # Delete ssh key
run: rm -rf ~/.ssh/id_rsa
+1 -3
View File
@@ -24,7 +24,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/table/relation"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/errs" "github.com/OpenIMSDK/tools/errs"
"github.com/OpenIMSDK/tools/log"
"github.com/OpenIMSDK/tools/mcontext" "github.com/OpenIMSDK/tools/mcontext"
"github.com/OpenIMSDK/tools/tx" "github.com/OpenIMSDK/tools/tx"
"github.com/OpenIMSDK/tools/utils" "github.com/OpenIMSDK/tools/utils"
@@ -223,7 +222,6 @@ func (f *friendDatabase) AgreeFriendRequest(
friendRequest *relation.FriendRequestModel, friendRequest *relation.FriendRequestModel,
) (err error) { ) (err error) {
return f.tx.Transaction(func(tx any) error { return f.tx.Transaction(func(tx any) error {
defer log.ZDebug(ctx, "return line")
now := time.Now() now := time.Now()
fr, err := f.friendRequest.NewTx(tx).Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID) fr, err := f.friendRequest.NewTx(tx).Take(ctx, friendRequest.FromUserID, friendRequest.ToUserID)
if err != nil { if err != nil {
@@ -249,7 +247,7 @@ func (f *friendDatabase) AgreeFriendRequest(
if err != nil { if err != nil {
return err return err
} }
} else if err != nil && errs.Unwrap(err) != gorm.ErrRecordNotFound { } else if errs.Unwrap(err) != gorm.ErrRecordNotFound {
return err return err
} }