0x01 Create Github repos
Create a repo for hosting static files
Just create a public repo named yourname.github.io
.
Create a repo for building static files
Create a PRIVATE repo (contains secret information) named blog-deploy
.
0x02 Create a SSH key and add to Github
Create a SSH key
1 | $ ssh-keygen |
Save it to another place and don’t override ~/.ssh/id_rsa
!!
Add your key to Github
First, copy the text in id_rsa.pub
and add it to your Github.
Go to blog-deploy
repo and go to Settings -> Secrets
, add a new secret named ACTIONS_DEPLOY_KEY
and fill it with id_rsa
which you just created.
0x03 Get and modify Hexo code
Get Hexo code and push
1 | $ git clone https://github.com/hexojs/hexo-starter blog-deploy |
Modify Hexo deploy script
Scroll to the end of blog-deploy/_config.yml
and edit deploy
section:
1 | deploy: |
Add Github workflow
Create blog-deploy/.github/workflows/Deploy.yml
.
1 | name: Deploy |
0x04 Push your blog to Github
1 | $ git add . |
0x05 Turn on Github Pages
Go to yourname.github.io
Settings -> Options -> Github Pages
and turn it on.