liuyuqi-dellpc 2 years ago
parent
commit
09f85c15ed
7 changed files with 177 additions and 32 deletions
  1. 62 0
      .github/workflows/deploy.yml
  2. 6 1
      README.md
  3. 0 30
      Summary.md
  4. 5 0
      docs/README.md
  5. 6 1
      docs/Summary.md
  6. 73 0
      tools/add_footer.py
  7. 25 0
      tools/build.py

+ 62 - 0
.github/workflows/deploy.yml

@@ -0,0 +1,62 @@
+name: deploy docs to server
+
+on:
+  push:
+    branches: [ master ]
+
+env:
+  TZ: Asia/Shanghai
+
+jobs:
+  build:
+    strategy:
+      matrix:
+        node-version: [14.x]
+        os: [ubuntu-latest]
+        include:
+        - os: ubuntu-latest
+          path: ~/.cache/pip
+
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v2
+        
+      - name: Set up Python 3.8
+        id: setup-python
+        uses: actions/setup-python@v2
+        with:
+          python-version: 3.8
+        
+      - name: Install dependencies
+        run: |
+          python -m pip install --upgrade pip
+          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+  
+      - name: build docs
+        run: |
+          pwd
+          sh tools/build_docs.sh
+
+    # docs/.vuepress/dist
+
+      - name: deploy to server
+        uses: appleboy/scp-action@master
+        with:
+          host: ${{ secrets.HOST }}
+          username: ${{ secrets.USERNAME }}
+          port: ${{ secrets.PORT }}
+          password: ${{ secrets.PASSWORD }}
+          source: "site/"
+          target: ${{ secrets.TARGET }}
+      
+      - name: User Nodejs
+        uses: actions/setup-node@v1
+        with:
+          node-version: ${{ matrix.node-version }}
+      
+      - name: build
+        run: |
+          npm install
+          npm run build
+          npm run deploy

+ 6 - 1
README.md

@@ -1,4 +1,9 @@
-# next-note
+
+---
+title: 项目介绍
+date: 2023-05-02 12:00:00
+---
+    # next-note
 
 
 This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
 This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
 
 

+ 0 - 30
Summary.md

@@ -1,30 +0,0 @@
-# Summary
-
-* [快速入门](introduction/index.md)
-	* [NativeScript介绍](introduction/introduction.md)
-	* [环境搭建](introduction/environment_build.md)
-	* [Hello World](introduction/tutorials.md)
-
-* [布局](layout/index.md)
-    * [UI设计,布局](layout/design.md)
-	* [组件](layout/comonet.md)
-	* [样式](layout/style.md)
-	* [事件](layout/event.md)
-	* [生命周期](layout/lifezq.md)
-
-* [基础功能](base/index.md)
-    * [数据库](base/database.md)
-	* [网络请求](base/network.md)
-	* [Native硬件](base/native_method.md)
-
-* [ns 包](ns_package/index.md)
-    * [ns 命令行](ns_package/ns_command_line.md)
-	* [ns core包](ns_package/ns_core.md)
-	* [ns 社区包](ns_package/ns_community.md)
-	* [ns 包开发教程](ns_package/ns_package_dev.md)
-
-* [其他](other/index.md)
-    * [关于我们](other/about_us.md)
-	* [常见问题](other/questions.md)
-	* [商务合作](other/coor.md)
-	

+ 5 - 0
docs/README.md

@@ -1,3 +1,8 @@
+
+---
+title: 项目介绍
+date: 2023-05-02 12:00:00
+---
 # docs
 # docs
 
 
 
 

+ 6 - 1
docs/Summary.md

@@ -1,4 +1,9 @@
-# Summary
+
+---
+title: 项目介绍
+date: 2023-05-02 12:00:00
+---
+    # Summary
 
 
 * [快速入门](introduction/index.md)
 * [快速入门](introduction/index.md)
 	* [NativeScript介绍](introduction/introduction.md)
 	* [NativeScript介绍](introduction/introduction.md)

+ 73 - 0
tools/add_footer.py

@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/05/03 13:47:45
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   add header to all markdown files
+'''
+import os,logging
+
+logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
+logger = logging.getLogger(__name__)
+
+def add_header():
+    """
+    param parameter_list:
+    return:
+    """
+    header='''---
+title: 项目介绍
+date: 2023-05-02 12:00:00
+---
+
+''' 
+    for root, dirs, files in os.walk("../"):
+        for file in files:
+            if file.endswith('.md'):
+                try:
+                    with open(os.path.join(root,file),'r+',encoding='utf-8') as f:
+                        content=f.read()
+                        if content.startswith('---') or content.startswith('\n---'):
+                            logger.info('file {} already has header'.format(os.path.join(root,file)))
+                        else:
+                            f.seek(0,0)
+                            f.write(header)
+                            f.write(content)
+                            logger.info('file {} add header success'.format(os.path.join(root,file)))
+                        f.close()
+                except Exception as e:
+                    logger.error('file {} add header failed'.format(os.path.join(root,file)))
+                    logger.error(e)
+                    continue
+
+def add_footer():
+    '''
+    add footer to all markdown files
+    '''
+    copyright='''
+    ## 版权说明:
+
+本文档版权隶属 天问科技 ,**仅用于天问科技旗下公司,团队为客户展示项目案例所用**,任何盗用本公司图文,描述,案例的行为均属违法,我们保留追究法律责任的权利。
+
+'''
+    for root, dirs, files in os.walk("../"):
+        for file in files:
+            if file.endswith('.md'):
+                with open(file,'a+',encoding='utf-8') as f:
+                    content=f.read()
+                    if content.find('## 版权说明:')!=-1:
+                        logger.info('file {} already has footer'.format(file))
+                    else:
+                        f.write('\n'+copyright)
+                    f.close()
+
+def run():
+    '''
+    run
+    '''
+    add_header()
+    add_footer()
+
+if __name__=='__main__':
+    run()

+ 25 - 0
tools/build.py

@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2023/05/02 20:50:44
+@License :   Copyright © 2017-2022 liuyuqi. All Rights Reserved.
+@Desc    :   build website or pdf book
+'''
+
+import os
+
+def build_pdf():
+    '''
+    build pdf
+    '''
+    os.system('gitbook pdf .')
+
+def build_web():
+    '''
+    build web
+    '''
+    os.system('gitbook build .')
+
+if __name__=='__main__':
+    build_pdf()