From ff933cb18dfb325b7361d0aad50cb1860011ca7e Mon Sep 17 00:00:00 2001 From: zengjia Date: Fri, 4 Aug 2023 14:34:37 +0800 Subject: [PATCH] ci: update --- .github/diff.js | 4 ++-- .github/workflows/pr-compressed-size.yml | 27 ++++++++++++++++++++++-- .github/workflows/test-build.yml | 2 +- package.json | 2 +- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.github/diff.js b/.github/diff.js index b983a8379..ce87dfde0 100644 --- a/.github/diff.js +++ b/.github/diff.js @@ -6,7 +6,7 @@ const core = require('@actions/core') function init() { const DEPLOY_DOMAIN = process.env.DEPLOY_DOMAIN | 'https://yuanshen.site/docs/' - const OUT_DIR = process.env.OUT_DIR | 'dist' + const OUT_DIR = process.env.OUT_DIR | core.toPlatformPath('./src/_dist') let result = '' let outRange = false @@ -70,7 +70,7 @@ function init() { const { changedFiles, newFiles } = compareFilesWithHash( calculateHashForHTMLFiles(OUT_DIR == 0 ? 'dist' : OUT_DIR), - calculateHashForHTMLFiles('_site') + calculateHashForHTMLFiles('dist') ) if (changedFiles.length === 0 && newFiles.length === 0) { diff --git a/.github/workflows/pr-compressed-size.yml b/.github/workflows/pr-compressed-size.yml index 4832c3211..4af9564ca 100644 --- a/.github/workflows/pr-compressed-size.yml +++ b/.github/workflows/pr-compressed-size.yml @@ -8,10 +8,33 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@main + with: + # “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录 + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: '16' + + # cache node_modules + - name: Cache pnpm modules + uses: actions/cache@v2 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}- + + - name: Install dependencies + uses: pnpm/action-setup@v2 + with: + run_install: true + + - name: Build Site + run: pnpm build + - uses: preactjs/compressed-size-action@v2 with: - build-script: 'build' clean-script: 'rm -rf dist/' pattern: './build/**/*.{js,css,html,json}' exclude: '{./build-output/manifest.json,**/*.map,**/node_modules/**}' diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 7707043ba..ae918a53c 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -37,7 +37,7 @@ jobs: run: pnpm site:preview - run: | - zip -r _site.zip ./dist + zip -r _site.zip ./src/_dist - name: upload _site artifact uses: actions/upload-artifact@v2 diff --git a/package.json b/package.json index 112c0909e..8861dacc8 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "lint:prettier": "prettier --check .", "lint:zh": "zhlint 'docs/**/*.md'", "serve": "vitepress serve --base /docs/", - "site:preview": "vitepress build" + "site:preview": "vitepress build --outDir _dist" }, "lint-staged": { "*.{js,ts,vue}": [