xgqfrms / Gatsby-Tutorials-All-In-One

Gatsby-Tutorials-All-In-One
https://gatsby-react-app.xgqfrms.xyz
MIT License
1 stars 0 forks source link

cnblogs 迁移到 github 指南 All In One #6

Open xgqfrms opened 1 year ago

xgqfrms commented 1 year ago

cnblogs 迁移到 github 指南 All In One

cnblogs

https://cnblogs.xgqfrms.xyz/

solutions

方案二:拿来主义

  1. master/main 分支,自动构建 public/dist 文件夹
  2. 使用第三方的 github actions , 把构建出来的 public/dist 文件夹,deploy 到 gh-pages 分支根目录中

    gh-pages 分支 / 根目录作为部署目录

https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/

https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/issues/4

https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/blob/master/package.json#L13-L14

 {
   "scripts": {
     "copy": "cp ./README.md ./static/",
     "deploy": "npm run copy && gatsby build",
  }
}

https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/blob/master/.github/workflows/deploy-gh-pages.yml

name: Auto Deploy Gatsby to gh-pages
on:
  push:
    branches: [ "master" ]
    # branches: [ "master", "main" ]
  schedule:
    # 定时任务 crontab, 每周五的 21:24 分自动执行一次
    # Runs at 21:24 UTC on Fri. Actions schedules run at most every 5 minutes
    # https://docs.github.com/actions/reference/workflow-syntax-for-github-actions#onschedule
    - cron: '24 21 * * 5'
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build-and-deploy:
    concurrency: ci-${{ github.ref }}
    # Recommended if you intend to make multiple deployments in quick succession.
    runs-on: ubuntu-latest
    steps:
      - name: checkout 🛎️
        uses: actions/checkout@v3
      # - name: Run a one-line script ✅ 👨🏻‍💻
      #   run: echo 正在执行单个命令! ✅
      - name: Install and Build 🔧
        # This example project is built using npm and outputs the result to the 'public' folder.
        # Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
        run: |
          echo 正在执行多个命令! ✅✅
          npm i -f
          npm run deploy
        # run: |
        #   echo 正在执行 npm install
        #   npm i
        #   npm run deploy
        # run: |
        #   echo 正在执行多个命令! ✅✅
        #   npm ci
        #   npm run deploy

      - name: start deploy
        run: echo “开始部署 ...⌛️ ”
      - name: Deploy to gh-pages 🚀
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: public
          # The folder the action should deploy.
          token: ${{ secrets.ACCESS_TOKEN }}
      - name: Run a one-line script
        run: echo “部署完成 ✅”

方案一:自食其力

  1. 使用 gh-pages 分支,作为 master/main 分支,无需使用第三方的 github actions
  2. 自定义 shell 脚本,实现 install, build, copy, depoly 一条龙服务

    gh-pages 分支使用 /docs/ 文件夹作为部署目录

https://github.com/xgqfrms/cnblogs

https://github.com/xgqfrms/cnblogs/actions/runs/2797175417

image

https://github.com/xgqfrms/cnblogs/blob/gh-pages/copy.sh

#!/usr/bin/env bash

# echo "^-v-^ copying files ..." && yarn copy
echo "^-v-^ create folder ..." && mkdir docs
echo "^-v-^ copying README.md ..." && cp ./CNAME ./docs
echo "^-v-^ copying CNAME ..." && cp ./CNAME ./docs
echo "^-v-^ copying files ..." && cp -r ./website/public/* ./docs

https://github.com/xgqfrms/cnblogs/blob/gh-pages/.github/workflows/deploy.yml

# This is a basic workflow to help you get started with Actions

name: AUTO_DEPLOY

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the gh-pages branch
  push:
    branches: [ gh-pages ]
  pull_request:
    branches: [ gh-pages ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # chmod +x ./install.sh
      # chmod +x ./dev.sh 
      # chmod +x ./app.sh 
      # chmod +x ./copy.sh 

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: ./install.sh

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: ./app.sh

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: ./clean.sh

      # rm -rf -Y bug, rm -rf & rimraf ???

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: ./copy.sh

      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: |
          echo install finished ✅,
          echo build finished ✅,
          echo deploy finished ✅.

      # todos...

#  ./app.sh && ./copy.sh
xgqfrms commented 1 year ago

备份

image

没有可以备份的数据!❌

https://i1.cnblogs.com/BlogBackup.aspx

image

CNBlogs_BlogBackup_131_201607_202210.xml

xgqfrms commented 1 year ago

审核博客园内的所有文章

网站整改公告

为了遵守相关法律法规,合法合规运营,网站进行全面整改,整改工作于2021年3月18日12:00开始,预计于3月25日11:59结束,整改期间全站无法发布任何内容,之前发布的内容重新审核后才能访问,由此给您带来很大的麻烦,请您谅解。

2021-03-18 07:01

https://www.cnblogs.com/cmt/p/14553189.html

https://www.zhihu.com/question/449973287

???

https://github.com/zeusro/MarkdownBlog

https://www.cnblogs.com/zeusro/

https://www.cnblogs.com/jackson0714/p/cnblogs1.html

https://github.com/Jackson0714

https://www.cnblogs.com/liminjun88/p/4823903.html

https://github.com/liminjun/liminjun.github.io/issues/3

https://www.cnblogs.com/missile/p/11781522.html

https://github.com/dashenxian

https://zhuanlan.zhihu.com/p/95206699

https://github.com/hackerchenzhuo

https://hackerchenzhuo.github.io/index.html

https://www.cnblogs.com/zhangyjblogs/p/16103863.html

https://github.com/zhangyjblogs

https://www.cnblogs.com/RyanXing/p/14307823.html

https://github.com/RyanXingQL/Blog

https://www.cnblogs.com/fei8899/p/14347049.html

xgqfrms commented 1 year ago

https://github.com/xgqfrms/cnblogs/issues/17

xgqfrms commented 1 year ago
博客搬家指南 / 博客迁移指南 # cnblogs https://cnblogs.xgqfrms.xyz/ https://github.com/xgqfrms/cnblogs/actions/runs/2797175417 ## solutions 方案二:拿来主义 1. master/main 分支,自动构建 public/dist 文件夹 2. 使用第三方的 github actions , 把构建出来的 public/dist 文件夹,deploy 到 gh-pages 分支根目录中 gh-pages 分支 `/` 根目录作为部署目录 https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/ https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/issues/4 https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/blob/master/package.json#L13-L14 ```js { "scripts": { "copy": "cp ./README.md ./static/", "deploy": "npm run copy && gatsby build", } } ``` https://github.com/xgqfrms/Gatsby-Tutorials-All-In-One/blob/master/.github/workflows/deploy-gh-pages.yml ```yaml name: Auto Deploy Gatsby to gh-pages on: push: branches: [ "master" ] # branches: [ "master", "main" ] schedule: # 定时任务 crontab, 每周五的 21:24 分自动执行一次 # Runs at 21:24 UTC on Fri. Actions schedules run at most every 5 minutes # https://docs.github.com/actions/reference/workflow-syntax-for-github-actions#onschedule - cron: '24 21 * * 5' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: permissions: contents: write jobs: build-and-deploy: concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. runs-on: ubuntu-latest steps: - name: checkout 🛎️ uses: actions/checkout@v3 # - name: Run a one-line script ✅ 👨🏻‍💻 # run: echo 正在执行单个命令! ✅ - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'public' folder. # Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. run: | echo 正在执行多个命令! ✅✅ npm i -f npm run deploy # run: | # echo 正在执行 npm install # npm i # npm run deploy # run: | # echo 正在执行多个命令! ✅✅ # npm ci # npm run deploy - name: start deploy run: echo “开始部署 ...⌛️ ” - name: Deploy to gh-pages 🚀 uses: JamesIves/github-pages-deploy-action@v4 with: folder: public # The folder the action should deploy. token: ${{ secrets.ACCESS_TOKEN }} - name: Run a one-line script run: echo “部署完成 ✅” ``` 方案一:自食其力 1. 使用 gh-pages 分支,作为 master/main 分支,无需使用第三方的 github actions 3. 自定义 shell 脚本,实现 install, build, copy, depoly 一条龙服务 gh-pages 分支使用 `/docs/` 文件夹作为部署目录 https://github.com/xgqfrms/cnblogs ![image](https://user-images.githubusercontent.com/7291672/198679329-9830b4b6-dbd0-4686-b85c-afb0da475e96.png) https://github.com/xgqfrms/cnblogs/blob/gh-pages/copy.sh ```sh #!/usr/bin/env bash # echo "^-v-^ copying files ..." && yarn copy echo "^-v-^ create folder ..." && mkdir docs echo "^-v-^ copying README.md ..." && cp ./CNAME ./docs echo "^-v-^ copying CNAME ..." && cp ./CNAME ./docs echo "^-v-^ copying files ..." && cp -r ./website/public/* ./docs ``` https://github.com/xgqfrms/cnblogs/blob/gh-pages/.github/workflows/deploy.yml ```yml # This is a basic workflow to help you get started with Actions name: AUTO_DEPLOY # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the gh-pages branch push: branches: [ gh-pages ] pull_request: branches: [ gh-pages ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "build" build: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 # chmod +x ./install.sh # chmod +x ./dev.sh # chmod +x ./app.sh # chmod +x ./copy.sh # Runs a single command using the runners shell - name: Run a one-line script run: ./install.sh # Runs a single command using the runners shell - name: Run a one-line script run: ./app.sh # Runs a single command using the runners shell - name: Run a one-line script run: ./clean.sh # rm -rf -Y bug, rm -rf & rimraf ??? # Runs a single command using the runners shell - name: Run a one-line script run: ./copy.sh # Runs a set of commands using the runners shell - name: Run a multi-line script run: | echo install finished ✅, echo build finished ✅, echo deploy finished ✅. # todos... # ./app.sh && ./copy.sh ```