Skip to content

Deploy your Hugo site to GitHub Pages, via GitHub Actions, with Arch Linux.

Notifications You must be signed in to change notification settings

reuixiy/hugo-deploy

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hugo-deploy

Deploy your Hugo site to GitHub Pages, via GitHub Actions, with Arch Linux.

Prerequisites

  • Git your Hugo site

Usage

  1. Generate SSH public/private key pair

    ssh-keygen -t rsa -b 4096 -C "username@users.noreply.github.com"
  2. Add deploy key to GitHub Pages repository

    Copy the generated id_rsa.pub to your clipboard, then add it to your GitHub Pages repository.

    Note that the "Allow write access" must be checked.

    See https://docs.github.com/en/developers/overview/managing-deploy-keys#setup-2

  3. Add secret key to the source code repository

    Copy the generated id_rsa to your clipboard, then add it to the source code repository.

    Note that the Name must be DEPLOY_KEY.

    See https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#creating-encrypted-secrets-for-a-repository

  4. Add workflow

    Refer to the example workflow below.

  5. Commit and push changes

Example workflow

# .github/workflows/build.yml

name: build

on:
  push:
    branches:
    - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: 'Building...'
      uses: reuixiy/hugo-deploy@v1
      env:
        DEPLOY_REPO: username/username.github.io
        DEPLOY_BRANCH: build
        DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
        # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
        TZ: Asia/Shanghai

Additional Notes

  • With Arch Linux, hugo-deploy will always use the latest extended version of Hugo, check it here.
  • In order to ensure the cleanliness of the GitHub Pages repository, hugo-deploy won't keep the commits history of DEPLOY_BRANCH, which means there is always only one commit in that branch.
  • Example badge: [![GitHub Actions](https://github.com/reuixiy/io-oi.me/workflows/build/badge.svg)](https://github.com/reuixiy/io-oi.me/actions)
  • If the source code is on GitHub Pages repository, then the step 2 and step 3 are in the same repository.
  • If the DEPLOY_BRANCH is build, you may need to choose a publishing source for your GitHub Pages after the first build.
  • If you want to add a custom domain for your GitHub Pages site, you may need to add a static/CNAME file to your Hugo site, with your domain name in it.
  • Enforcing HTTPS for your GitHub Pages site.

Acknowledgements

https://github.com/Xuanwo/blog/blob/35504e96a1/.github/actions/hugo/entrypoint.sh