Skip to content

Commit

Permalink
ci: update
Browse files Browse the repository at this point in the history
  • Loading branch information
jiazengp committed Aug 4, 2023
1 parent b21d238 commit ff933cb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/pr-compressed-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**}'
2 changes: 1 addition & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}": [
Expand Down

0 comments on commit ff933cb

Please sign in to comment.