GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. Make code reviews, branch management, and issue triaging work the way you want.
I use Github Actions to deploy site source files (eg: hugoBlog source) to GitHub Pages (eg: liugangjian.github.io ) automatically .
My blog project architecture is shown below. In the figure we can clearly see there are three repositories.
- liugangjian.github.io is a public repository which includes the output after build.
- hugoBlog Source is a private repository which contains the source code of the website.
- draw.io is a public repository which saved the pictures used in the article.
In the hugoBlog Source file directory, create a .github/workflows/deploy.yml file, when pushing code to hugoBlog repo, github action will help me to build and deploy the target to liugangjian.github.io
# This is a basic workflow to help you get started with Actions
name: hugo-deploy-CI
# Controls when the action will run.
on: push
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# docs:https://github.com/peaceiris/actions-gh-pages
deploy:
runs-on: ubuntu-18.04
steps:
- name: Git checkout
uses: actions/checkout@v2
- name: Setup hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.81.0'
extended: true
- name: Build
run: hugo
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.PERSONAL_TOKEN }}
external_repository: liugangjian/liugangjian.github.io
publish_dir: ./public
keep_files: true
publish_branch: master