瀏覽代碼

workflow: update workflow

陈凯龙 3 年之前
父節點
當前提交
8b823af6a9
共有 5 個文件被更改,包括 80 次插入10 次删除
  1. 69 0
      .github/workflows/deploy-gitee.yml
  2. 6 6
      .github/workflows/deploy.yml
  3. 2 2
      .vitepress/config.js
  4. 1 1
      guide/auth.md
  5. 2 1
      package.json

+ 69 - 0
.github/workflows/deploy-gitee.yml

@@ -0,0 +1,69 @@
+name: Docs Deploy Gitee
+
+on:
+  push:
+    branches:
+      - master
+
+jobs:
+  push-to-gh-pages-gitee:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v2
+
+      - name: Use Node.js 16
+        uses: actions/setup-node@v2.1.2
+        with:
+          node-version: '16.x'
+
+      - name: Get Yarn Cache
+        id: yarn-cache
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+
+      - name: Cache Dependencies
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarn-cache.outputs.dir }}
+          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
+          restore-keys: |
+            ${{ runner.os }}-yarn-
+
+      - name: Set SSH Environment
+        env:
+          DOCS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
+        run: |
+          mkdir -p ~/.ssh/
+          echo "$ACTIONS_DEPLOY_KEY" > ~/.ssh/id_rsa
+          chmod 600 ~/.ssh/id_rsa
+          ssh-keyscan github.com > ~/.ssh/known_hosts
+          chmod 700 ~/.ssh && chmod 600 ~/.ssh/*
+          git config --local user.email "321200875@qq.com"
+          git config --local user.name "kailong321200875"
+
+      - name: Build
+        run: |
+          yarn install
+          yarn run build:gitee
+
+      - name: Docs Deploy Gitee
+        uses: peaceiris/actions-gh-pages@v3
+        with:
+          deploy_key: ${{secrets.ACTIONS_DEPLOY_KEY}}
+          publish_branch: gh-pages-gitee
+          publish_dir: ./.vitepress/dist
+          keep_files: true
+
+      - name: Sync Github Repos To Gitee # 名字随便起
+        uses: Yikun/hub-mirror-action@v1.1 # 使用Yikun/hub-mirror-action
+        with:
+          src: github/kailong321200875 # 源端账户名(github)
+          dst: gitee/kailong110120130 # 目的端账户名(gitee)
+          dst_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} # SSH密钥对中的私钥
+          dst_token: ${{ secrets.GITEE_TOKEN }} # Gitee账户的私人令牌
+          account_type: user # 账户类型
+          clone_style: 'https' # 使用https方式进行clone,也可以使用ssh
+          debug: true # 启用后会显示所有执行命令
+          force_update: true # 启用后,强制同步,即强制覆盖目的端仓库
+          static_list: 'vue-element-plus-admin-doc' # 静态同步列表,在此填写需要同步的仓库名称,可填写多个
+          timeout: '600s' # git超时设置,超时后会自动重试git操作

+ 6 - 6
.github/workflows/main.yml → .github/workflows/deploy.yml

@@ -1,4 +1,4 @@
-name: docs-deploy
+name: Docs Deploy
 
 on:
   push:
@@ -12,16 +12,16 @@ jobs:
       - name: Checkout
         uses: actions/checkout@v2
 
-      - name: use Node.js 16
+      - name: Use Node.js 16
         uses: actions/setup-node@v2.1.2
         with:
           node-version: '16.x'
 
-      - name: Get yarn cache
+      - name: Get Yarn Cache
         id: yarn-cache
         run: echo "::set-output name=dir::$(yarn cache dir)"
 
-      - name: Cache dependencies
+      - name: Cache Dependencies
         uses: actions/cache@v2
         with:
           path: ${{ steps.yarn-cache.outputs.dir }}
@@ -44,9 +44,9 @@ jobs:
       - name: Build
         run: |
           yarn install
-          yarn run build
+          yarn run build:github
 
-      - name: Deploy
+      - name: Docs Deploy
         uses: peaceiris/actions-gh-pages@v3
         with:
           deploy_key: ${{secrets.ACTIONS_DEPLOY_KEY}}

+ 2 - 2
.vitepress/config.js

@@ -3,7 +3,7 @@
  * @type {import('vitepress').UserConfig}
  */
 module.exports = {
-  base: '/',
+  base: (process.argv[3] && process.argv[3] === 'gitee') ? '/vue-element-plus-admin-doc/' : '/',
   title: 'vue-element-plus-admin',
   lang: 'zh-CN',
   description: '一套基于vue3、element-plus、typesScript4、vite2的后台集成方案',
@@ -84,7 +84,7 @@ function createNav() {
           link: '/components/form',
         },
         {
-          text: '函数式',
+          text: '函数式组件',
           link: '/components/image-viewer',
         },
       ],

+ 1 - 1
guide/auth.md

@@ -217,5 +217,5 @@ const redirectPath = from.query.redirect || to.path
 const redirect = decodeURIComponent(redirectPath as string)
 const nextData = to.path === redirect ? { ...to, replace: true } : { path: redirect }
 permissionStore.setIsAddRouters(true)
-next(to.path === '/' ? { path: permissionStore.addRouters[0]?.path as string } : nextData)
+next(nextData)
 ```

+ 2 - 1
package.json

@@ -7,7 +7,8 @@
   "license": "MIT",
   "scripts": {
     "dev": "vitepress dev",
-    "build": "vitepress build",
+    "build:github": "vitepress build github",
+    "build:gitee": "vitepress build gitee",
     "serve": "vitepress serve"
   },
   "devDependencies": {