The GitHub page has been built normally using HEXO
Configure Hexo to automatically deploy Github Page based on github Action
Go to Mo Shuying’s personal website to check out the pure version
1. Set an 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"
Copy the code
Skip the password and all, just hit enter three times
Then we’ll get two key files that we’ll use later
2. Upload the private key
Github repository address → Settings → Secrets → New Secret
Click on thenew repository secret
New Warehouse key
Name HEXO_DEPLOY_PRI Content Github -deploy-key All contents in the file
⚠ Do not easily disclose your private key ⚠
3. Upload the public key
Github does not support uploading multiple repositories to the same (deployed) public key
Different warehouse
If your Hexo code is not in the same repository as the page to be deployed
For example, if you have some content that is not convenient to expose for the time being, or if you don’t want to expose your Hexo code, you just want to deploy static pages (text, images, various styles and scripts used for the site theme) to Github pages without any other content
At this point you need to upload the public key to the repository you want to deploy
Name HEXO_DEPLOY_PUB contents github-deploy-key.pub ‘all contents in the file
Remember to check allow write permission
The same warehouse
This is similar to the previous step, except that the repository address uploaded is the same as your repository address, but you must make sure that you have the branch with the correct number in the configuration
Configuration is making the action
You can go to Github and go to Action -> New Workflow -> Set Up a Workflow Yourself You can also add a hexo-ci.yml file to the.github/ Workflow repository and put the following into that file.
Remember to put theblog_source_branch
.username
.[email protected]
Replace it 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 The ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: The ${{ 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 "
" git config --global user.email "
"
@email.address>
- name: Install dependencies
run: | npm i -g hexo-cli npm i - name: Deploy hexo
run: | hexo clean && hexo generate && hexo deployCopy the code
Then commit this change
Configuration Hexo deploy
Open _config.yml in the repository to change the Git repository from HTTP to SSH. The branch that publishes the deployment file should be the same as the repository configuration branch
deploy:
type: git
repo: [email protected]:moshuying/moshuying.github.io.git
# example, https://github.com/hexojs/hexojs.github.io
branch: master
Copy the code
You’ve done everything! Push it once to see the effect.
References and recommendations
Hexo runs shader and Threejs
Hexo automatically builds with Github Action (in various forms)