The GitHub Pages service is open to every user for domain name resolution and hosting of
username.github.io. If you are an ordinary user, the Github-Page service will only be open to public repositories. After the repositories are converted to private, Github-Page will stop parsing And updates; for student Pro and paid Pro users and above, the Github-Page service will provide services for both public and private repositories, but Travis CI is only free for public repositories. In summary, this article is for guys who want to use GitHub Pages service for private repositories.
P.S. Privatizing the repository hosting Github-Page can reduce privacy leakage. However, all files (of the deployment branch) can still be crawled/scanned.
I have always used the most concise and straightforward
GitHub Pages and
Jekyll for blog writing. Recently, I was trembling at home because of the disease control problem, but I couldn’t stop studying and working, so I just did things that I haven’t had time to do.
- Private Github-Pages repository
- Use Hexo instead of Jekyll
- Use Github Action for automatic deployment
set up private key for deploy
Similar to the backup verification code in Google’s two-step verification, but google token is a single generation (visible/query) and destroyed after use, GitHub personal token is a single generation and destruction (invisible) multiple uses.
Developer settings >>
Personal access tokens, and click
Generate new token.
Deploying a blog only requires read and write permissions to the repo. The token will not be visible after this page is closed (write it down!!).
Because the branch deployed by the Github-Pages service is
main by default, there are two common repository setting methods as follows:
- Double repository: repository A is used to store Hexo source files, repository B (xxx.github.io) is used to deploy Hexo generated files, push A triggers GitHub Action to update deployment repository B
- Single repository: source branch is used to store Hexo source files,
mainbranch is used to deploy Hexo generated files, push source triggers GitHub Action to update
mainand deploy Github-Pages
Here I am using a single-repository dual-branch setting. Be careful not to merge manually, otherwise, it will take time (history will disappear after the action refreshes the
We cannot store the token generated in the previous step in plaintext, so we need to set it as the Secrets of the repository so that the token can be implicitly referenced by Secrets. Enter (in the repository)
Add a new secret, fill in the name with
GITHUB_ACCESS_TOKEN, and fill in the token just now.
_config.yml, and modify the following id and repository name to your own.
Create a new
.github/workflows/blogci.yml in the root directory of Hexo, the content is as follows, modify the git information to your own：
Finally, you can also use another way of writing (using local installation to avoid npm installation dependency errors)：
- name: Hexo
Save it and push it to GitHub, and then enter Actions and you will find that BlogCI is already working.
At present, GitHub Action adopts a free time marketing strategy:
- 2000 minutes of free usage per month for common users
- 3000 minutes of free usage per month for pro users
According to my statistics, the execution time of successful push action is between 40~60s, and the execution time of longer (3~5min) is generally an error :(
According to this time to estimate, the user does not need to spend extra on the action :)
- Github-Pages service
- Jekyll framework
- Google backup verification code
- Hexo Docs