Merge branch 'dev' into feat/1.0.5/deltag

This commit is contained in:
aichy126 2023-02-17 11:39:13 +08:00
commit a66f104d02
8 changed files with 118 additions and 115 deletions

62
.github/workflows/build_dev_img.yml vendored Normal file
View File

@ -0,0 +1,62 @@
name: Build Dev Image
on:
push:
branches: [ "test","dev" ]
jobs:
build:
name: Build and Push
runs-on: [self-hosted,linux]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.IMG_URL }}/${{ secrets.IMG_NAMESPACE }}/answer
tags: |
type=raw,value=latest
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.IMG_URL }}
username: ${{ secrets.IMG_USERNAME }}
password: ${{ secrets.IMG_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./.github/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
sync-git:
name: Sync to Git
runs-on: [self-hosted,linux]
needs:
- build
steps:
- name: Sync to Gitlab
uses: aiworklab/git-mirror-action@master
env:
SSH_PRIVATE_KEY: ${{ secrets.GITLAB_RSA_PRIVATE_KEY }}
with:
source-repo: git@github.com:answerdev/answer.git
destination-repo: ${{ secrets.GITLAB_REPO }}

View File

@ -2,7 +2,7 @@ name: Build DockerHub Image
on:
push:
branches: [ "main","githubaction","test" ]
branches: [ "main"]
tags:
- v2.*
- v1.*

42
.github/workflows/build_test.yml vendored Normal file
View File

@ -0,0 +1,42 @@
name: Build Test
on:
push:
branches:
- 'dev'
pull_request:
branches:
- 'dev'
jobs:
node-build-test:
name: Node Build Test
runs-on: [self-hosted, linux]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-node@v3
with:
node-version: 16
- name: Test Build
run: make install-ui-packages ui
go-build-test:
name: Go Build Test
runs-on: [self-hosted, linux]
needs:
- node-build-test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Go Test Build
run: make clean build

View File

@ -1,24 +0,0 @@
name: Go Build Test
on:
push:
branches: [ "main","githubaction","test" ]
pull_request:
branches: [ "main" ]
jobs:
go-build-test:
runs-on: [self-hosted, linux]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Go Test Build
run: make clean build

View File

@ -1,22 +0,0 @@
name: Node Build Test
on:
push:
branches: [ "main","githubaction","test"]
pull_request:
branches: [ "main" ]
jobs:
node-build-test:
runs-on: [self-hosted, linux]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-node@v3
with:
node-version: 16
- name: Test Build
run: make install-ui-packages ui

View File

@ -5,48 +5,8 @@ include:
file: ".deploy-helm.yml"
stages:
- compile-html
- compile-golang
- push
- deploy-dev
"compile the html and other static files":
image: node:16
stage: compile-html
before_script:
- npm config set registry https://repo.huaweicloud.com/repository/npm/
- make install-ui-packages
script:
- make ui
artifacts:
paths:
- ./build
"compile the golang project":
image: golang:1.18
stage: compile-golang
# before_script:
# - export GOPROXY=https://goproxy.cn,direct
script:
- make build
artifacts:
paths:
- ./answer
"build docker images and push":
stage: push
# before_script:
# - export GOPROXY=https://goproxy.cn,direct
extends: .docker-build-push
only:
- test
variables:
DockerNamespace: sf_app
DockerImage: answer
DockerTag: "$CI_COMMIT_SHORT_SHA latest"
DockerfilePath: .
PushPolicy: qingcloud
"deploy-to-local-develop-environment":
stage: deploy-dev
extends: .deploy-helm

View File

@ -7,49 +7,33 @@ env:
before:
hooks:
- go mod tidy
release:
draft: true
builds:
- id: build-amd64
- id: build
main: ./cmd/answer/.
binary: answer
ldflags: -s -w -X main.Version={{.Version}} -X main.Revision={{.ShortCommit}} -X main.Time={{.Date}} -X main.BuildUser=goreleaser
flags: -v
goos:
- linux
- darwin
goarch:
- amd64
- arm64
- id: build-windows
main: ./cmd/answer/.
binary: answer
ldflags: -s -w -X main.Version={{.Version}} -X main.Revision={{.ShortCommit}} -X main.Time={{.Date}} -X main.BuildUser=goreleaser
flags: -v
goos:
- windows
goarch:
- amd64
- id: build-arm64
main: ./cmd/answer/.
binary: answer
ldflags: -s -w -X main.Version={{.Version}} -X main.Revision={{.ShortCommit}} -X main.Time={{.Date}} -X main.BuildUser=goreleaser
goos:
- linux
goarch:
- arm64
- id: build-darwin-arm64
main: ./cmd/answer/.
binary: answer
goos:
- darwin
goarch:
- arm64
ldflags: -s -w -X main.Version={{.Version}} -X main.Revision={{.ShortCommit}} -X main.Time={{.Date}} -X main.BuildUser=goreleaser
flags: -v
- id: build-darwin-amd64
main: ./cmd/answer/.
binary: answer
goos:
- darwin
goarch:
- amd64
ldflags: -s -w -X main.Version={{.Version}} -X main.Revision={{.ShortCommit}} -X main.Time={{.Date}} -X main.BuildUser=goreleaser
flags: -v
archives:
@ -70,3 +54,4 @@ changelog:
- '^test:'
# goreleaser release --snapshot --rm-dist

View File

@ -74,7 +74,7 @@ func (ur *UserRankRepo) checkUserMinRank(ctx context.Context, session *xorm.Sess
isReachStandard bool, err error,
) {
bean := &entity.User{ID: userID}
_, err = session.Select("rank").Get(bean)
_, err = session.Select("`rank`").Get(bean)
if err != nil {
return false, errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}