Deploy your Hugo site to GitHub Pages, via GitHub Actions, with Arch Linux.
- Git your Hugo site
-
Generate SSH public/private key pair
ssh-keygen -t rsa -b 4096 -C "[email protected]"
-
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
-
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 beDEPLOY_KEY
. -
Add workflow
Refer to the example workflow below.
-
Commit and push changes
# .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
- 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
isbuild
, 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.