From 7ab05d262f157a2cf6f46268dad2d1ffc64ff436 Mon Sep 17 00:00:00 2001 From: Peach Date: Mon, 31 Jul 2023 11:41:34 +0800 Subject: [PATCH] refactor: enable dist hash by default (#1802) * refactor: enable dist hash by default * ci: update build script * ci: set node version * ci: set node version * ci: remove useless preview ci * refactor: correct logic --- .github/workflows/preview-build.yml | 55 ------- .github/workflows/preview-deploy.yml | 137 ------------------ .github/workflows/preview-start.yml | 31 ---- .../preset-dumi/src/plugins/features/init.ts | 13 +- 4 files changed, 8 insertions(+), 228 deletions(-) delete mode 100644 .github/workflows/preview-build.yml delete mode 100644 .github/workflows/preview-deploy.yml delete mode 100644 .github/workflows/preview-start.yml diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml deleted file mode 100644 index 24fe66f237..0000000000 --- a/.github/workflows/preview-build.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Preview Build - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - build-preview: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - name: build - run: | - yarn - yarn build - yarn doc:build - - - run: | - zip -r dist.zip dist - - - name: upload dist artifact - uses: actions/upload-artifact@v2 - with: - name: dist - path: dist.zip - retention-days: 5 - - - name: build mobile - run: | - DUMI_THEME=./packages/theme-mobile yarn doc:build - - - run: | - zip -r dist-mobile.zip dist - - - name: upload dist artifact - uses: actions/upload-artifact@v2 - with: - name: dist-mobile - path: dist-mobile.zip - retention-days: 5 - - - name: Save PR number - if: ${{ always() }} - run: echo ${{ github.event.number }} > ./pr-id.txt - - - name: Upload PR number - if: ${{ always() }} - uses: actions/upload-artifact@v2 - with: - name: pr - path: ./pr-id.txt diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml deleted file mode 100644 index a9ed096b24..0000000000 --- a/.github/workflows/preview-deploy.yml +++ /dev/null @@ -1,137 +0,0 @@ -name: Preview Deploy - -on: - workflow_run: - workflows: ["Preview Build"] - types: - - completed - -jobs: - success: - runs-on: ubuntu-latest - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' - steps: - - name: download pr artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: pr - - name: save PR id - id: pr - run: echo "::set-output name=id::$( - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - run: | - rm -rf dist/ - - name: download dist artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - workflow_conclusion: success - name: dist-mobile - - run: | - unzip dist-mobile.zip - - name: upload surge service - id: deploy-mobile - run: | - export DEPLOY_DOMAIN=https://dumi-mobile-preview-pr-${{ steps.pr.outputs.id }}.surge.sh - npx surge --project ./dist --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }} - - name: update status comment - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 🎊 PR Mobile Preview has been successfully built and deployed to https://dumi-mobile-preview-pr-${{ steps.pr.outputs.id }}.surge.sh - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - name: The job failed - if: ${{ failure() }} - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 😭 Deploy PR Preview failed. - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - name: The job mobile failed - if: ${{ failure() }} - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 😭 Deploy PR Mobile Preview failed. - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - failed: - runs-on: ubuntu-latest - if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' - steps: - - name: download pr artifact - uses: dawidd6/action-download-artifact@v2 - with: - workflow: ${{ github.event.workflow_run.workflow_id }} - name: pr - - name: save PR id - id: pr - run: echo "::set-output name=id::$( - - - body-include: '' - number: ${{ steps.pr.outputs.id }} - - name: The job mobile failed - if: ${{ failure() }} - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - 😭 Deploy PR Mobile Preview failed. - - - - - body-include: '' - number: ${{ steps.pr.outputs.id }} diff --git a/.github/workflows/preview-start.yml b/.github/workflows/preview-start.yml deleted file mode 100644 index 3a98781a39..0000000000 --- a/.github/workflows/preview-start.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Preview Start - -on: pull_request_target - -jobs: - preview: - runs-on: ubuntu-latest - steps: - - name: create - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - ⚡️ Deploying PR Preview... - - - - - body-include: '' - - - name: create mobile - uses: actions-cool/maintain-one-comment@v1.1.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - body: | - ⚡️ Deploying PR Mobile Preview... - - - - - body-include: '' diff --git a/packages/preset-dumi/src/plugins/features/init.ts b/packages/preset-dumi/src/plugins/features/init.ts index 3d5af71420..52eab2364b 100644 --- a/packages/preset-dumi/src/plugins/features/init.ts +++ b/packages/preset-dumi/src/plugins/features/init.ts @@ -35,12 +35,15 @@ export default (api: IApi) => { }); // re-enable @ & @@ umi default alias for integrated mode - if (isIntegrateUmi || api.args?.dumi) { - api.modifyDefaultConfig(memo => { + api.modifyDefaultConfig(memo => { + if (isIntegrateUmi || api.args?.dumi) { memo.alias['@'] = api.paths.absSrcPath; memo.alias['@@'] = api.paths.absTmpPath; + } + + // enable dist hash by default + memo.hash = true; - return memo; - }); - } + return memo; + }); };