From c7a782b24ccabb12c690d3c2f88d949d8ce75b3d Mon Sep 17 00:00:00 2001 From: joyceliu Date: Thu, 26 Oct 2023 16:55:35 +0800 Subject: [PATCH] feat: add github action --- .github/workflows/main.yaml | 68 +++++++++++++++++++++++++++ .github/workflows/manually.yaml | 63 +++++++++++++++++++++++++ .github/workflows/nightly-builds.yaml | 62 ++++++++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 .github/workflows/main.yaml create mode 100644 .github/workflows/manually.yaml create mode 100644 .github/workflows/nightly-builds.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000000..b87cd4b8cb6 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,68 @@ +name: Main + +on: + push: + # Publish `master` as Docker `latest` image. + branches: +# - master +# - dev + - release-* + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + # Run build for any PRs. + pull_request: + +jobs: + build-and-push: + runs-on: self-hosted + + strategy: + matrix: + node-version: [12.18.x] + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: npm i -g yarn && yarn + + - name: Build + run: yarn build + + - name: Test + run: yarn test + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Docker login + if: github.event_name == 'push' + uses: docker/login-action@v1 + with: + registry: registry.cn-beijing.aliyuncs.com + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Push image + if: github.event_name == 'push' + run: | + TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') REPO=registry.cn-beijing.aliyuncs.com/kubesphereio make container-cross-push + + - name: slack + uses: 8398a7/action-slack@v3 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + status: ${{ job.status }} + fields: repo,message,commit,author,action,eventName,ref,workflow,job,took + if: failure() \ No newline at end of file diff --git a/.github/workflows/manually.yaml b/.github/workflows/manually.yaml new file mode 100644 index 00000000000..bb50f0b73c1 --- /dev/null +++ b/.github/workflows/manually.yaml @@ -0,0 +1,63 @@ +name: ManuallyCrossBuild + +on: + workflow_dispatch: + +jobs: + build-and-push: + runs-on: self-hosted + + strategy: + matrix: + node-version: [12.18.x] + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: npm i -g yarn && yarn + + - name: Build + run: yarn build + + - name: Test + run: yarn test + + - name: Set up QEMU + if: github.event_name == 'push' + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + if: github.event_name == 'push' + id: buildx + uses: docker/setup-buildx-action@v1 + with: + version: v0.7.1 + install: true + + - name: Docker login + if: github.event_name == 'push' + uses: docker/login-action@v1 + with: + registry: registry.cn-beijing.aliyuncs.com + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Push image + if: github.event_name == 'push' + run: | + TAG=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') REPO=registry.cn-beijing.aliyuncs.com/kubesphereio make container-cross-push + + - name: slack + uses: 8398a7/action-slack@v3 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + with: + status: ${{ job.status }} + fields: repo,message,commit,author,action,eventName,ref,workflow,job,took + if: failure() \ No newline at end of file diff --git a/.github/workflows/nightly-builds.yaml b/.github/workflows/nightly-builds.yaml new file mode 100644 index 00000000000..c465212a1e0 --- /dev/null +++ b/.github/workflows/nightly-builds.yaml @@ -0,0 +1,62 @@ +name: NightlyBuild + +on: + schedule: + # This is a UTC time + - cron: "0 16 * * *" + # Keep it only for test purpose, comment it once everything is ok + workflow_dispatch: + +jobs: + build-and-push: + runs-on: self-hosted + + strategy: + matrix: + node-version: [ '14.x' ] + + steps: + - uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: | + git branch + npm i -g yarn && yarn + + - name: Build + run: yarn build + + - name: Test + run: yarn test + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + + - name: Docker login + uses: docker/login-action@v1 + with: + registry: registry.cn-beijing.aliyuncs.com + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Push image + run: | + TAG=nightly-$(date '+%Y%m%d') REPO=registry.cn-beijing.aliyuncs.com/kubesphereio make container-cross-push + +# - name: slack +# uses: 8398a7/action-slack@v3 +# env: +# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} +# with: +# status: ${{ job.status }} +# fields: repo,message,commit,author,action,eventName,ref,workflow,job,took +# if: failure() \ No newline at end of file