Skip to content
GitHub Actions for deploying to GitHub Pages with Static Site Generators
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Create FUNDING.yml (#2) May 24, 2019
images add: images and is-not-branch-deleted action Jun 12, 2019
.dockerignore add: action May 21, 2019
Dockerfile
LICENSE add: action May 21, 2019
README.md add: images and is-not-branch-deleted action Jun 12, 2019
entrypoint.sh fix: shellcheck errors May 26, 2019

README.md

license release GitHub release date

GitHub Actions for deploying to GitHub Pages with Static Site Generators

GitHub Actions for deploying to GitHub Pages

A GitHub Action to deploy your static site to GitHub Pages with Static Site Generators (Hugo, MkDocs, Gatsby, GitBook, etc.)

Getting started

(1) Add deploy Key

Generate deploy key with the following command.

ssh-keygen -t rsa -b 4096 -C "your@email.com" -f gh-pages -N ""

# You will get 2 files:
#   gh-pages.pub (public key)
#   gh-pages     (private key)

Next, Go to Repository Settings

  • Go to Deploy Keys and add your public key with the "Allow write access"
  • Go to Secrets and add your private key as ACTIONS_DEPLOY_KEY

(2) Create main.workflow

An example with Hugo action.

peaceiris/actions-hugo latest version peaceiris/actions-gh-pages latest version

workflow "GitHub Pages" {
  on = "push"
  resolves = ["deploy"]
}

action "is-branch-master" {
  uses = "actions/bin/filter@master"
  args = "branch master"
}

action "is-not-branch-deleted" {
  uses = "actions/bin/filter@master"
  args = "not deleted"
}

action "build" {
  needs = ["is-branch-master", "is-not-branch-deleted"]
  uses = "peaceiris/actions-hugo@v0.55.6"
  args = ["--gc", "--minify", "--cleanDestinationDir"]
}

action "deploy" {
  needs = "build"
  uses = "peaceiris/actions-gh-pages@v1.0.1"
  env = {
    PUBLISH_DIR = "./public"
    PUBLISH_BRANCH = "gh-pages"
  }
  secrets = ["ACTIONS_DEPLOY_KEY"]
}
Workflow overview Actions log
GitHub Actions for deploying to GitHub Pages Workflow overview GitHub Actions for deploying to GitHub Pages Actions log

Examples

MkDocs

peaceiris/actions-gh-pages latest version

workflow "MkDocs workflow" {
  on = "push"
  resolves = ["deploy"]
}

action "branch-filter" {
  uses = "actions/bin/filter@master"
  args = "branch master"
}

action "pipenv-sync" {
  needs = ["branch-filter"]
  uses = "peaceiris/actions-pipenv@3.6"
  args = "sync"
}

action "mkdocs-build" {
  needs = ["pipenv-sync"]
  uses = "peaceiris/actions-pipenv@3.6"
  args = ["run", "mkdocs", "build", "--config-file", "./mkdocs-sample.yml"]
}

action "deploy" {
  needs = ["mkdocs-build"]
  uses = "peaceiris/actions-gh-pages@v1.0.1"
  env = {
    PUBLISH_DIR = "./site"
    PUBLISH_BRANCH = "gh-pages"
  }
  secrets = ["ACTIONS_DEPLOY_KEY"]
}

License

MIT License - peaceiris/actions-gh-pages

About the author

peaceiris - Patreon

You can’t perform that action at this time.