Merge remote-tracking branch 'github/githubaction' into github-dev

This commit is contained in:
LinkinStars 2023-02-08 17:15:30 +08:00
commit 4fb84da1c1
6 changed files with 76 additions and 72 deletions

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

@ -0,0 +1,63 @@
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: .
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.*

View File

@ -1,8 +1,6 @@
name: Go Build Test
on:
push:
branches: [ "main","githubaction","test" ]
pull_request:
branches: [ "main" ]

View File

@ -1,8 +1,6 @@
name: Node Build Test
on:
push:
branches: [ "main","githubaction","test"]
pull_request:
branches: [ "main" ]

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