GitBook GitHub Actios

  1. GitBook + GitHub Actios + Gitee Pages
    1. 1,gitbook安装使用
    2. 2,github actions
    3. 3,yml脚本编写
  2. 仓库同步
  3. Gitee Pages Action

GitBook + GitHub Actios + Gitee Pages

1,gitbook安装使用

https://meliauk.gitee.io/note/Gitbook.html

2,github actions

选择仓库 – 点击Actions – 创建

创建一个actions

3,yml脚本编写

GITEE_PRIVATE_KEY

本地电脑运行 ssh-keygen -t rsa -C "youremail@example.com"

C:\Users\用户名\.ssh\
    |--id_rsa(私钥)
    |--id_rsa.pub(公钥)
    |--known_hosts(不用管)

GITEE_TOKEN

gitee上设置私人令牌获得token,然后在github仓库中添加《repository secret》

GITEE_PASSWORD

你的gitee账号的密码

设置GITEE_TOKEN GITEE_PRIVATE_KEY image-20230825122612723
name: 同步到gitee并page
on: [push]
jobs:
  # get-gitee-code:
  #   runs-on: ubuntu-latest
  #   steps:
  #   - name: Sync to Gitee
  #     uses: Yikun/hub-mirror-action@master
  #     with:
  #       src: gitee/MEliauk
  #       dst: github/meliauk
  #       dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
  #       dst_token: ${{ secrets.GITBUB_TOKEN }}
  #       static_list: "ddbug"
        
  build-and-push:
    permissions:
        contents: write
        id-token: write
        pull-requests: write
        issues: write
        repository-projects: write
        deployments: write
        packages: write
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@master
      
    - name: Use Node@10.14.1 # 步骤2
      uses: actions/setup-node@v1 # 作用:安装nodejs
      with:
        node-version: 10.14.1
        
    - name: Set node version to ${{ matrix.node_version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node_version }}
        cache: 'npm'
    
    - name: Install gitbook
      run: npm install -g gitbook-cli
      
    - name: Install gitbook-plugin-lightbox
      run: npm install gitbook-plugin-lightbox

    - name: gitbook install
      run: gitbook install 

    - name: gitbook build
      run: gitbook build 

    - name: CommitPush
      run: |
        git config --global user.email 2050781802@qq.com
        git config --global user.name meliauk
        git add .
        git commit -m"action:`date`"
        git pull
        git push -f origin master
  sync:
    needs: build-and-push
    runs-on: ubuntu-latest
    steps:
    - name: Sync to Gitee
      uses: Yikun/hub-mirror-action@master
      with:
        src: github/meliauk
        dst: gitee/MEliauk
        dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
        dst_token: ${{ secrets.GITEE_TOKEN }}
        force_update: true
        static_list: "ddbug"
  reload-pages:
    needs: sync
    runs-on: ubuntu-latest
    steps:
      - name: Build Gitee Pages
        uses: yanglbme/gitee-pages-action@main
        with:
          # 注意替换为你的 Gitee 用户名
          gitee-username: MEliauk
          # 注意在 Settings->Secrets 配置 GITEE_PASSWORD
          gitee-password: ${{ secrets.GITEE_PASSWORD }}
          # 注意替换为你的 Gitee 仓库,仓库名严格区分大小写,请准确填写,否则会出错  
          gitee-repo: MEliauk/ddbug
          # 要部署的分支,默认是 master,若是其他分支,则需要指定(指定的分支必须存在)
          branch: master
          directory: _book

仓库同步

https://github.com/Yikun/hub-mirror-action

https://baijiahao.baidu.com/s?id=1755870736498576093&wfr=spider&for=pc

Gitee Pages Action

https://github.com/yanglbme/gitee-pages-action


日夜颠倒头发少 ,单纯好骗恋爱脑 ,会背九九乘法表 ,下雨只会往家跑 ,搭讪只会说你好 ---- 2050781802@qq.com

×

喜欢就点赞,疼爱就打赏

相册 说点什么