头图

hexo cooperates with github action to build automatically (various forms)

article contains online demonstration effects, please visit Mo

warehouse link , click a free star, thank you very much.

has been used to build the GitHub page

Automatically deploy github page according to github action to hexo configuration

success.png

Go to Mo Shuying's personal website to view the pure version

1. Set the access key for the warehouse

The first step is to generate a key, open the command line and generate a set of keys

ssh-keygen -f github-deploy-key -C "HEXO CD"

<!-- more -->

Remember to skip the password or something, just press enter three times here

setup-1.png

Then we will get two key files, these two will be used later

list-key-files.png

2. Upload the private key

github warehouse address → Settings → Secrets → New secret

upload-private-key.png

Click new repository secret create a new warehouse key

Name HEXO_DEPLOY_PRI
Content github-deploy-key All content in the file

upload-private-key-2.png

reveal your private key

3. Upload the public key

Here to distinguish your warehouse -> page format , the warehouse where the public key is uploaded represents the warehouse to be deployed, github does not support uploading the same (deployed) public key to multiple warehouses

Different warehouses

If your hexo code and the page to be deployed are not in the same warehouse

For example, you have some content that is temporarily inconvenient to disclose, or you do not want to disclose your Hexo code, but only want to deploy static pages (text, images, various styles and scripts used by the website theme) to the github page. Other content will not be available. Include

At this point you need to upload the public key to the warehouse you want to deploy

upload-public-key.png

Name`HEXO_DEPLOY_PUB
Content github-deploy-key.pub All content in the file

upload-private-key-2.png

Remember to check to allow write permissions

Same warehouse

Similar to the previous step, except that the uploaded warehouse address is the same as your code warehouse address, but you must make sure you have a branch with the correct number in the configuration

Configure github action

Here you can click on GitHub Action -> new workflow -> set up a workflow yourself just pick a template content into them, can also be in the code repository .github/workflow add a hexo-ci.yml then the following into the file.

Remember to blog_source_branch , username , username@email.address with your own

name: HEXO CI

on:
  push:
    branches:
    - <blog_source_branch>

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x]

    steps:
      - uses: actions/checkout@v1

      - name: Use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v1
        with:
          node-version: ${{ matrix.node-version }}

      - name: Configuration environment
        env:
          HEXO_DEPLOY_PRI: ${{secrets.HEXO_DEPLOY_PRI}}
        run: |
          mkdir -p ~/.ssh/
          echo "$HEXO_DEPLOY_PRI" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          git config --global user.name "<username>"
          git config --global user.email "<username@email.address>"
      - name: Install dependencies
        run: |
          npm i -g hexo-cli
          npm i
      - name: Deploy hexo
        run: |
          hexo clean && hexo generate && hexo deploy

Then submit this change

Configure Hexo deploy

_config.yml in the code warehouse
Change the git repository from http form to ssh form.
The branch that publishes the deployment file should be the same as the branch configured in the warehouse

deploy:
  type: git
  repo: git@github.com:moshuying/moshuying.github.io.git
  # example, https://github.com/hexojs/hexojs.github.io
  branch: master

You have completed all operations! Push once to see the effect.

References and recommendations


前端与算法
前端与算法系列合集

msy.plus

74 声望
11 粉丝
0 条评论
推荐阅读
【css灵感】模拟3D地球
在css中有3d变换的方法,一般用它做一些矩形的效果,如果是圆形则比较困难了。这里用一种障眼法的方式实现了3d的效果。点击这里查看无纯净广告版实现方法 {代码...}

墨抒颖1阅读 1.2k

ESlint + Stylelint + VSCode自动格式化代码(2023)
安装插件 ESLint,然后 File -&gt; Preference-&gt; Settings(如果装了中文插件包应该是 文件 -&gt; 选项 -&gt; 设置),搜索 eslint,点击 Edit in setting.json

谭光志34阅读 20.8k评论 9

安全地在前后端之间传输数据 - 「3」真的安全吗?
在「2」注册和登录示例中,我们通过非对称加密算法实现了浏览器和 Web 服务器之间的安全传输。看起来一切都很美好,但是危险就在哪里,有些人发现了,有些人嗅到了,更多人却浑然不知。就像是给门上了把好锁,还...

边城32阅读 7.3k评论 5

封面图
涨姿势了,有意思的气泡 Loading 效果
今日,群友提问,如何实现这么一个 Loading 效果:这个确实有点意思,但是这是 CSS 能够完成的?没错,这个效果中的核心气泡效果,其实借助 CSS 中的滤镜,能够比较轻松的实现,就是所需的元素可能多点。参考我们...

chokcoco24阅读 2.3k评论 3

在前端使用 JS 进行分类汇总
最近遇到一些同学在问 JS 中进行数据统计的问题。虽然数据统计一般会在数据库中进行,但是后端遇到需要使用程序来进行统计的情况也非常多。.NET 就为了对内存数据和数据库数据进行统一地数据处理,发明了 LINQ (L...

边城17阅读 2k

封面图
过滤/筛选树节点
又是树,是我跟树杠上了吗?—— 不,是树的问题太多了!🔗 相关文章推荐:使用递归遍历并转换树形数据(以 TypeScript 为例)从列表生成树 (JavaScript/TypeScript) 过滤和筛选是一个意思,都是 filter。对于列表来...

边城18阅读 7.9k评论 3

封面图
Vue2 导出excel
2020-07-15更新 excel导出安装 {代码...} src文件夹下新建一个libs文件夹,新建一个excel.js {代码...} vue页面中使用 {代码...} ===========================以下为早期的文章今天在开发的过程中需要做一个Vue的...

原谅我一生不羁放歌搞文艺14阅读 20.1k评论 9

msy.plus

74 声望
11 粉丝
宣传栏