From dcd2ba84a4e9a3b2322f79a7c1adf5276d4fd8c6 Mon Sep 17 00:00:00 2001 From: Bowen Tan Date: Mon, 29 Jul 2024 11:19:50 +0800 Subject: [PATCH] add ci --- .github/workflows/ci-check.yml | 36 +++++++++++++++++++++++++ .github/workflows/publish.yml | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 .github/workflows/ci-check.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci-check.yml b/.github/workflows/ci-check.yml new file mode 100644 index 00000000..c95630a3 --- /dev/null +++ b/.github/workflows/ci-check.yml @@ -0,0 +1,36 @@ +name: "CI Check" + +on: + pull_request: + branches: ["main"] + +# Cancel prev CI if new commit come +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: [self-hosted, linux] + strategy: + matrix: + node: [16] + name: Run Test on Node ${{ matrix.node }} + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - name: Setup yarn + run: npm install -g yarn + - name: Install deps + run: yarn install --frozen-lockfile + timeout-minutes: 15 + - name: Go to refine + run: cd packages/refine + - name: Test + run: yarn jest + - name: Build + run: yarn build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..e9d87281 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,48 @@ +name: publish + +on: + push: + tags: + - "*" + +jobs: + publish: + if: startsWith(github.ref, 'refs/tags/v') + runs-on: [self-hosted, linux] + strategy: + matrix: + node: [16] + name: Publish on Node ${{ matrix.node }} + steps: + - name: checkout + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + - name: Setup yarn + run: npm install -g yarn + - name: Install deps + run: yarn install --frozen-lockfile + timeout-minutes: 15 + - name: Go to refine + run: cd packages/refine + - name: Build + run: yarn build + - name: Write .npmrc + env: + NPM_TOKEN: ${{ secrets.MY_NPM_TOKEN }} + run: | + echo //registry.npmjs.org/:_authToken=$NPM_TOKEN > ~/.npmrc + - name: Publish + uses: nick-fields/retry@v2 + with: + timeout_minutes: 10 # 设置超时时间,单位为分钟 + max_attempts: 3 # 设置最大重试次数 + command: | + npm publish + - name: sync cnpm + run: curl --location --request PUT 'http://192.168.26.29:7002/sync/@dovetail-v2/refine?sync_upstream=true' + - name: Clean .npmrc + if: always() + run: rm ~/.npmrc