From 491bd8f471bf3e80065bc304166627baf1521704 Mon Sep 17 00:00:00 2001 From: warjiang <1096409085@qq.com> Date: Wed, 11 Sep 2024 18:13:58 +0800 Subject: [PATCH] ci: setup ci-workflow for PR (#115) * ci: add all target in Makefile Signed-off-by: warjiang <1096409085@qq.com> * ci: add ci-workflow actions Co-authored-by: Hongcai Ren Signed-off-by: warjiang <1096409085@qq.com> --------- Signed-off-by: warjiang <1096409085@qq.com> Co-authored-by: Hongcai Ren --- .github/workflows/ci.yml | 54 ++++++++++++++++++++++++++++++++++++++++ Makefile | 6 ++++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..e0a8a4a5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +# Reference: https://github.com/karmada-io/karmada/blob/master/.github/workflows/ci.yml +# We cut some unused job to make the workflow more suitable for ci of karmada dashboard +name: CI Workflow +on: + # Run this workflow every time a new commit pushed to upstream/fork repository. + # Run workflow on fork repository will help contributors find and resolve issues before sending a PR. + push: + # Exclude branches created by Dependabot to avoid triggering current workflow + # for PRs initiated by Dependabot. + branches-ignore: + - 'dependabot/**' + pull_request: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency +concurrency: + group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +permissions: + contents: read # for actions/checkout to fetch code +jobs: + build-frontend: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + - uses: pnpm/action-setup@v4 + with: + version: 8.15.6 + - name: Build dashboard + run: | + echo "Start build" + pnpm --version + cd ui + pnpm install -w + pnpm run dashboard:build + build-bin: + name: build-bin + runs-on: ubuntu-22.04 + steps: + - name: checkout code + uses: actions/checkout@v4 + with: + # Number of commits to fetch. 0 indicates all history for all branches and tags. + # We need to guess version via git tags. + fetch-depth: 0 + - name: install Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: compile + run: make all diff --git a/Makefile b/Makefile index 78905c84..f37a33b6 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,8 @@ REGISTRY_USER_NAME ?= "" REGISTRY_PASSWORD ?= "" REGISTRY_SERVER_ADDRESS ?= "" -TARGETS := karmada-dashboard-api +TARGETS := karmada-dashboard-api \ + karmada-dashboard-web \ # Build binary. @@ -24,6 +25,8 @@ TARGETS := karmada-dashboard-api $(TARGETS): BUILD_PLATFORMS=$(GOOS)/$(GOARCH) hack/build.sh $@ +.PHONY: all +all: $(TARGETS) # Build image. # @@ -52,3 +55,4 @@ image-karmada-dashboard-web: BUILD_PLATFORMS=linux/$(GOARCH) hack/build.sh karmada-dashboard-web cp -R ui/apps/dashboard/dist _output/bin/linux/$(GOARCH)/dist DOCKER_FILE="build-web.Dockerfile" VERSION=$(VERSION) REGISTRY=$(REGISTRY) BUILD_PLATFORMS=linux/$(GOARCH) hack/docker.sh karmada-dashboard-web +