From 0fc9c1ed6c04181385afcb5323555f5c194b7184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9C=93=E6=BC=A0Nimbus?= <136771156+Nimbus318@users.noreply.github.com> Date: Sun, 29 Sep 2024 17:40:39 +0800 Subject: [PATCH] Create ci.yml --- .github/workflows/ci.yml | 89 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f13f202 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,89 @@ +name: Build and Push Images + +on: + push: + branches: [ "main" ] + tags: + - v[0-9]+.[0-9]+.[0-9]+.[0-9]+ + - v[0-9]+.[0-9]+.[0-9]+ + - v[0-9]+.[0-9]+ + pull_request: + branches: [ "main" ] + +env: + GO_VERSION: "1.22.5" + +jobs: + build-and-push-frontend: + name: Build and Push Frontend Image + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get branch names. + id: branch-names + uses: tj-actions/branch-names@v8 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to DockerHub + uses: docker/login-action@v3.1.0 + with: + username: ${{ secrets.DOCKERHUB_TOKEN }} + password: ${{ secrets.DOCKERHUB_PASSWD }} + + - name: Build and push frontend image + uses: docker/build-push-action@v6 + with: + platforms: linux/amd64,linux/arm64 + push: true + tags: projecthami/hami-webui-fe:${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }} + + golang-lint: + name: Lint Go Code + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go environment + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Run golint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.60 + args: "--timeout=5m ./server/..." + + build-and-push-backend: + name: Build and Push Backend Image + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + + - name: Get branch names. + id: branch-names + uses: tj-actions/branch-names@v8 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to DockerHub + uses: docker/login-action@v3.1.0 + with: + username: ${{ secrets.DOCKERHUB_TOKEN }} + password: ${{ secrets.DOCKERHUB_PASSWD }} + + - name: Build and push backend image + uses: docker/build-push-action@v6 + with: + context: ./server + platforms: linux/amd64,linux/arm64 + push: true + tags: projecthami/hami-webui-be:${{ steps.branch-names.outputs.current_branch || steps.branch-names.outputs.tag }}