From 4a6a14d4b50b2c377e1a126d4df0de511ced7a97 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 8 Feb 2023 14:14:11 +0800 Subject: [PATCH 1/5] update action goreleaser --- .goreleaser.yaml | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 9feb6d72..cf61b678 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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 + From 05110e13bff6b7df2e0765934fd9ea44c33e2028 Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:22:55 +0800 Subject: [PATCH 2/5] action --- .github/workflows/build_dev_img.yml | 62 +++++++++++++++++++++++ .github/workflows/build_dockerhub_img.yml | 2 +- .github/workflows/go_build_test.yml | 2 - .github/workflows/node_build_test.yml | 2 - 4 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build_dev_img.yml diff --git a/.github/workflows/build_dev_img.yml b/.github/workflows/build_dev_img.yml new file mode 100644 index 00000000..559cffc8 --- /dev/null +++ b/.github/workflows/build_dev_img.yml @@ -0,0 +1,62 @@ +name: Build Dev Image + +on: + push: + branches: [ "test","githubaction" ] + tags: + - "v*.*.*" + +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: . + 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: wearerequired/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 }} + diff --git a/.github/workflows/build_dockerhub_img.yml b/.github/workflows/build_dockerhub_img.yml index 1cec6b70..52f96621 100644 --- a/.github/workflows/build_dockerhub_img.yml +++ b/.github/workflows/build_dockerhub_img.yml @@ -2,7 +2,7 @@ name: Build DockerHub Image on: push: - branches: [ "main","githubaction","test" ] + branches: [ "main"] tags: - v2.* - v1.* diff --git a/.github/workflows/go_build_test.yml b/.github/workflows/go_build_test.yml index c3642487..aaac41ef 100644 --- a/.github/workflows/go_build_test.yml +++ b/.github/workflows/go_build_test.yml @@ -1,8 +1,6 @@ name: Go Build Test on: - push: - branches: [ "main","githubaction","test" ] pull_request: branches: [ "main" ] diff --git a/.github/workflows/node_build_test.yml b/.github/workflows/node_build_test.yml index 83639c78..202a263b 100644 --- a/.github/workflows/node_build_test.yml +++ b/.github/workflows/node_build_test.yml @@ -1,8 +1,6 @@ name: Node Build Test on: - push: - branches: [ "main","githubaction","test"] pull_request: branches: [ "main" ] From 85e06e63d317e0f5fbd5b4b27c4463419f4298ac Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 8 Feb 2023 16:29:20 +0800 Subject: [PATCH 3/5] update dev action --- .github/workflows/build_dev_img.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_dev_img.yml b/.github/workflows/build_dev_img.yml index 559cffc8..bb05a03d 100644 --- a/.github/workflows/build_dev_img.yml +++ b/.github/workflows/build_dev_img.yml @@ -41,6 +41,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . + file: ./.github/Dockerfile platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} From 2c40a061da42fcf6bb7d1425076777a7ea9c74da Mon Sep 17 00:00:00 2001 From: aichy126 <16996097+aichy126@users.noreply.github.com> Date: Wed, 8 Feb 2023 17:08:06 +0800 Subject: [PATCH 4/5] update dev action --- .github/workflows/build_dev_img.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_dev_img.yml b/.github/workflows/build_dev_img.yml index bb05a03d..cd218765 100644 --- a/.github/workflows/build_dev_img.yml +++ b/.github/workflows/build_dev_img.yml @@ -54,7 +54,7 @@ jobs: - build steps: - name: Sync to Gitlab - uses: wearerequired/git-mirror-action@master + uses: aiworklab/git-mirror-action@master env: SSH_PRIVATE_KEY: ${{ secrets.GITLAB_RSA_PRIVATE_KEY }} with: From 6bf83b2033fba43efb77926a72f3e2a06093c70a Mon Sep 17 00:00:00 2001 From: LinkinStars Date: Wed, 8 Feb 2023 17:12:37 +0800 Subject: [PATCH 5/5] docs(ci): Update CI configuration --- .gitlab-ci.yml | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f96e65ef..e2519366 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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