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 }}