Github Action to Automate Hugo extended for a Github Organization Pages
GitHub Actions for building Hugo extended and deploying to a Github Organization Pages Submodule Repository
GitHub Action for building and publishing Hugo-built site to a Github Organization Pages. Follow the Hosting on Github Organization Pages step by step instructions.
This action goes in the repository that will contain Hugo’s content and other source files, and expects public
to be a submodule
pointing to a repo named like organization.github.io
.
Inspired by khanhicetea/gh-actions-hugo-deploy-gh-pages
EMAIL
- The email that you would like to have your git push signed as.DEPLOY_KEY_PRIVATE
- Required your deploy key which has Write access
- Generate deploy key
ssh-keygen -t rsa -b 4096 -f hugo -q -N ""
- Then go to your repo named
<orgname>.github.io
and select "Settings > Deploy Keys" and click the "Add New" button - Add the contents of your public key (
hugo.pub
) to the Key field and select the "Allow write access" option. - Go to the repo named like
organization.github.io
that will contain the fully rendered version of your Hugo website - Add the github action as below (the file will go in
.github/main.workflow
) - Copy your private deploy key to
DEPLOY_KEY_PRIVATE
secret in "Settings > Secrets"
HUGO_VERSION
: optional, default is 0.56.3 - check all versions here
Works both with the new yaml workflow format, or the old hcl format, but just use one.
.github/workflows/push.yml
on: push
name: Deploy to GitHub Organization Pages
jobs:
filtersForGitHubActions:
name: Filters for GitHub Actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Filters for GitHub Actions
uses: actions/bin/filter@master
with:
args: branch master
- name: hugo-deploy-gh-org-pages
uses: StevenACoffman/hugo-deploy-gh-org-pages@v1.0.3
env:
DEPLOY_KEY_PRIVATE: ${{ secrets.DEPLOY_KEY_PRIVATE }}
EMAIL: ${{ secrets.EMAIL }}
HUGO_VERSION: 0.56.3
main.workflow
workflow "Deploy to GitHub Organization Pages" {
resolves = ["hugo-deploy-gh-org-pages"]
on = "push"
}
action "hugo-deploy-gh-org-pages" {
uses = "StevenACoffman/hugo-deploy-gh-org-pages@v1.0.3"
needs = ["Filters for GitHub Actions"]
secrets = [
"EMAIL",
"DEPLOY_KEY_PRIVATE"
]
env = {
HUGO_VERSION = "0.56.3"
}
}
action "Filters for GitHub Actions" {
uses = "actions/bin/filter@master"
args = "branch master"
}