A GitHub Action to deploy your static site to GitHub Pages with Static Site Generators (Hugo, MkDocs, Gatsby, GitBook, etc.)
- Generate deploy key
ssh-keygen -t rsa -b 4096 -C "[email protected]" -f gh-pages -N ""
- You will get 2 files:
gh-pages.pub
(public key) andgh-pages
(private key)
- You will get 2 files:
- Go to "Settings > Deploy Keys" of repository.
- Add your public key within "Allow write access" option.
- Go to "Settings > Secrets" of repository.
- Add your private key as
ACTIONS_DEPLOY_KEY
An example with Hugo action.
workflow "GitHub Pages" {
on = "push"
resolves = ["deploy"]
}
action "is-branch-master" {
uses = "actions/bin/filter@master"
args = "branch master"
}
action "build" {
needs = "is-branch-master"
uses = "peaceiris/[email protected]"
args = ["--gc", "--minify", "--cleanDestinationDir"]
}
action "deploy" {
needs = "build"
uses = "peaceiris/[email protected]"
env = {
PUBLISH_DIR = "./public"
PUBLISH_BRANCH = "gh-pages"
}
secrets = ["ACTIONS_DEPLOY_KEY"]
}