Skip to content

Commit

Permalink
ci: add workflows demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jiazengp authored Jul 28, 2023
1 parent 3eea72a commit 40b08be
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 11 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ jobs:
node-version: ${{ matrix.node_version }}
cache: pnpm

- name: Build project
env:
NODE_OPTIONS: --max_old_space_size=4096
run: pnpm build

- name: Build project (MPA)
env:
NODE_OPTIONS: --max_old_space_size=4096
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/demo/preview-publish.demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 文件名建议统一为 preview-publish
# 应用 preview.yml 的 demo

# name: PREVIEW_PUBLISH

# on:
# workflow_run:
# workflows: ["MAIN_PULL_REQUEST"]
# types:
# - completed

# jobs:
# call-preview:
# uses: kongying-tavern/docs/.github/workflows/preview.yml@next
# secrets:
# SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/demo/pull-request.demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 文件名建议统一为 pull-request.yml
# 应用 test-build.yml 的 demo
# 要求 package.json 提供 site:preview,base 应为 '/'

# name: MAIN_PULL_REQUEST

# on:
# pull_request:
# branches: [develop, main]
# types: [opened, synchronize, reopened]

# jobs:
# call-test-build:
# uses: kongying-tavern/docs/.github/workflows/test-build.yml@next
2 changes: 1 addition & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
# 删除服务器上目录里所有文件
# ARGS: '-avz --delete'
# 项目 build 后静态文件位置
SOURCE: '.vitepress/dist/'
SOURCE: './dist'
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_PORT: ${{ secrets.REMOTE_PORT }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
# deploy to gh-pages branch
target_branch: gh-pages
# deploy the default output dir
build_dir: .vitepress/dist
build_dir: ./dist
env:
# @See https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .github/workflows/pr-compressed-size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Compressed Size

on:
pull_request:
types: [opened, synchronize]

jobs:
compressed-size:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: 94dreamer/compressed-size-action@master
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
pattern: "./dist/**/*.{js,css}"
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
repository=${{github.repository}}
project_name=${repository#*/}
export DEPLOY_DOMAIN=https://kongying-tavern-preview-pr${{ steps.pr.outputs.id }}-$project_name.surge.sh
npx surge --project .vitepress/dist --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
npx surge --project ./dist --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
echo the preview URL is $DEPLOY_DOMAIN
echo "::set-output name=url::$DEPLOY_DOMAIN"
- name: update status comment
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:

# 构建
- name: Build
run: pnpm vitepress build --base /
run: pnpm site:preview

- run: |
zip -r _site.zip .vitepress/dist
zip -r _site.zip ./dist
- name: upload _site artifact
uses: actions/upload-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions .vitepress/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const productionHead: HeadConfig[] = [
export default defineConfig({
lastUpdated: true,
srcDir: 'src',
outDir: './dist',
srcExclude: [],
scrollOffset: 'header',
cleanUrls: true,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"lint:md": "markdownlint **/*.md && lint:zh",
"lint:prettier": "prettier --check .",
"lint:zh": "zhlint 'docs/**/*.md'",
"serve": "vitepress serve --base /docs/"
"serve": "vitepress serve --base /docs/",
"site:preview": "vitepress serve --base /"
},
"lint-staged": {
"*.{js,ts,vue}": [
Expand Down

0 comments on commit 40b08be

Please sign in to comment.