From 3c6630c5cc1caf4f2f042c493382ef0842e91013 Mon Sep 17 00:00:00 2001 From: ihavecoke Date: Thu, 13 Jun 2024 10:08:36 +0800 Subject: [PATCH] Add base github action --- .github/workflows/autocorrect.yml | 25 ++++++++++++++++ .github/workflows/build.yml | 33 +++++++++++++++++++++ .github/workflows/canary.yml | 48 +++++++++++++++++++++++++++++++ .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++ docusaurus.config.ts | 2 +- 5 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/autocorrect.yml create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/canary.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/autocorrect.yml b/.github/workflows/autocorrect.yml new file mode 100644 index 000000000..b5f72cf5a --- /dev/null +++ b/.github/workflows/autocorrect.yml @@ -0,0 +1,25 @@ +name: AutoCorrect +on: [pull_request] +jobs: + autocorrect: + name: Check text autocorrect + runs-on: ubuntu-latest + steps: + - name: Check out source + uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Check + uses: huacnlee/autocorrect-action@main + with: + use_npm: true + + - name: Report ReviewDog + if: failure() + uses: huacnlee/autocorrect-action@main + env: + REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + use_npm: true + reviewdog: true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..82d9a4062 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build +on: + pull_request: + push: + branches: + - "!main" + - "!canary" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build Test + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: yarn + + - name: install dependency npm + run: yarn + + - name: build canary env dist file + run: | + yarn build:canary diff --git a/.github/workflows/canary.yml b/.github/workflows/canary.yml new file mode 100644 index 000000000..4d3fc70c8 --- /dev/null +++ b/.github/workflows/canary.yml @@ -0,0 +1,48 @@ +name: Deploy Canary +on: + push: + branches: + - main + - canary + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy_canary: + name: build + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - name: Download ossutils zip + run: | + wget https://github.com/aliyun/ossutil/releases/download/v1.7.17/ossutil-v1.7.17-linux-amd64.zip + unzip ossutil-v1.7.17-linux-amd64.zip && cp ./ossutil-v1.7.17-linux-amd64/ossutil ${{github.workspace}}/ && chmod +x ${{github.workspace}}/ossutil + + - name: Test ossutil cli is ok + run: | + ${{github.workspace}}/ossutil --version + + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: yarn + + - name: install dependency npm + run: yarn + + - name: build canary env dist file + env: + PROXY: canary + run: | + yarn build + + - name: upload canary dist to oss + run: | + ${{github.workspace}}/ossutil cp dist/ oss://lb-assets/github/canary/longportapp.com/learn/wiki/ -u -r -j 10 -e oss-cn-hangzhou.aliyuncs.com -i ${{ secrets.FE_LB_ASSET_ACCESS_KEY_ID }} -k ${{ secrets.FE_LB_ASSET_ACCESS_KEY_SECRET }} --exclude "*.html" --meta=Cache-Control:max-age=31536000 + ${{github.workspace}}/ossutil cp dist/ oss://lb-assets/github/canary/longportapp.com/learn/wiki/ -u -r -j 10 -e oss-cn-hangzhou.aliyuncs.com -i ${{ secrets.FE_LB_ASSET_ACCESS_KEY_ID }} -k ${{ secrets.FE_LB_ASSET_ACCESS_KEY_SECRET }} --include "*.html" --meta=Cache-Control:no-cache diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..20f1863a6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,46 @@ +name: Deploy Release +on: + push: + branches: + - release + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + deploy_release: + name: build + timeout-minutes: 30 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + + - uses: actions/setup-node@v3 + with: + node-version: 16 + cache: yarn + + - name: Download ossutils zip + run: | + wget https://github.com/aliyun/ossutil/releases/download/v1.7.17/ossutil-v1.7.17-linux-amd64.zip + unzip ossutil-v1.7.17-linux-amd64.zip && cp ./ossutil-v1.7.17-linux-amd64/ossutil ${{github.workspace}}/ && chmod +x ${{github.workspace}}/ossutil + + - name: Test ossutil cli is ok + run: | + ${{github.workspace}}/ossutil --version + + - name: install dependency npm + run: yarn + + - name: build release env dist file + env: + PROXY: release + run: yarn build + + - name: upload canary dist to oss + run: | + ${{github.workspace}}/ossutil cp dist/ oss://lb-assets/github/release/longportapp.com/learn/wiki/ -u -r -j 10 -e oss-cn-hangzhou.aliyuncs.com -i ${{ secrets.FE_LB_ASSET_ACCESS_KEY_ID }} -k ${{ secrets.FE_LB_ASSET_ACCESS_KEY_SECRET }} --exclude "*.html" --meta=Cache-Control:max-age=31536000 + ${{github.workspace}}/ossutil cp dist/ oss://lb-assets/github/release/longportapp.com/learn/wiki/ -u -r -j 10 -e oss-cn-hangzhou.aliyuncs.com -i ${{ secrets.FE_LB_ASSET_ACCESS_KEY_ID }} -k ${{ secrets.FE_LB_ASSET_ACCESS_KEY_SECRET }} --include "*.html" --meta=Cache-Control:no-cache diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 1e47b5240..714ffde13 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -12,7 +12,7 @@ const i18n = require("./i18n/config"); const isDev = process.env.NODE_ENV !== "production"; -const targetPortalPath = process.env.Proxy === "canary" ? "https://m.longbridge.xyz" : "https://m.lbkrs.com"; +const targetPortalPath = process.env.PROXY === "canary" ? "https://m.longbridge.xyz" : "https://m.lbkrs.com"; const localAPIProxyPath = "/dev-proxy"; const apiProxyUrl = `${isDev ? localAPIProxyPath : targetPortalPath}/api/forward`;