From baad9d6f98bb03683f24cb61686aa9468e7e4398 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 30 May 2024 01:24:39 +0800 Subject: [PATCH] chore: add build github actions (#2672) * chore: add build github actions * chore: remove docker push * chore: update cache maven --- .github/workflows/backend-build.yml | 51 +++++++++++++ .github/workflows/docker-build-and-push.yml | 54 +++++++++++++ .github/workflows/frontend-build.yml | 84 +++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 .github/workflows/backend-build.yml create mode 100644 .github/workflows/docker-build-and-push.yml create mode 100644 .github/workflows/frontend-build.yml diff --git a/.github/workflows/backend-build.yml b/.github/workflows/backend-build.yml new file mode 100644 index 0000000000..a7b8e21abb --- /dev/null +++ b/.github/workflows/backend-build.yml @@ -0,0 +1,51 @@ +name: Backend Build + +on: + # push: + # branches: + # - devel + # pull_request: + # branches: + # - devel + # paths-ignore: + # - "webapp/**" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + # Allows you to reuse workflows by referencing their YAML files + workflow_call: + +jobs: + build-backend: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: "temurin" + java-version: "17" + cache: maven + + - name: Cache Maven packages + uses: actions/cache@v4 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Run build script + run: sudo ./build-backend.sh + shell: bash + working-directory: ./deploy + + - name: Archive build artifacts + uses: actions/upload-artifact@v4 + with: + name: backend-build-artifacts + path: deploy/cloudbeaver diff --git a/.github/workflows/docker-build-and-push.yml b/.github/workflows/docker-build-and-push.yml new file mode 100644 index 0000000000..f4fdfba72f --- /dev/null +++ b/.github/workflows/docker-build-and-push.yml @@ -0,0 +1,54 @@ +name: Build and Push Docker Image + +on: + # push: + # branches: + # - devel + # pull_request: + # branches: + # - devel + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + call-backend-build: + uses: ./.github/workflows/backend-build.yml + + call-frontend-build: + uses: ./.github/workflows/frontend-build.yml + + build-and-push-docker: + runs-on: ubuntu-latest + needs: [call-backend-build, call-frontend-build] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download backend artifacts + uses: actions/download-artifact@v4 + with: + name: backend-build-artifacts + path: deploy/cloudbeaver/ + + - name: Download frontend artifacts + uses: actions/download-artifact@v4 + with: + name: frontend-build-artifacts + path: deploy/cloudbeaver/web + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Run custom Docker build script + working-directory: ./deploy + run: | + chmod +x make-docker-container.sh + ./make-docker-container.sh + + - name: Tag Docker Image + run: | + IMAGE_NAME=dbeaver/cloudbeaver + TAG_NAME=${{ github.head_ref || github.ref_name }} + docker tag $IMAGE_NAME:dev $IMAGE_NAME:$TAG_NAME diff --git a/.github/workflows/frontend-build.yml b/.github/workflows/frontend-build.yml new file mode 100644 index 0000000000..bf964d522a --- /dev/null +++ b/.github/workflows/frontend-build.yml @@ -0,0 +1,84 @@ +name: Frontend Build + +on: + # push: + # branches: + # - devel + # pull_request: + # branches: + # - devel + # paths: + # - "webapp/**" + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + + # Allows you to reuse workflows by referencing their YAML files + workflow_call: + +jobs: + frontend-build: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./webapp + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v2 + with: + node-version: "20" + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: restore yarn cache + uses: actions/cache@v4 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: restore node_modules + uses: actions/cache@v4 + with: + path: "**/node_modules" + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node_modules- + + - name: restore typescript cache + uses: actions/cache@v4 + with: + path: "**/packages/*/dist" + key: ${{ runner.os }}-dist-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-dist- + + - name: yarn install + uses: borales/actions-yarn@v4 + with: + dir: webapp + cmd: install + + - name: yarn lerna bootstrap + uses: borales/actions-yarn@v4 + with: + dir: webapp + cmd: lerna bootstrap + + - name: build + uses: borales/actions-yarn@v4 + with: + dir: webapp/packages/product-default + cmd: bundle + + - name: Archive build artifacts + uses: actions/upload-artifact@v4 + with: + name: frontend-build-artifacts + path: webapp/packages/product-default/lib