Skip to content

GitHub Action

GitHub Pages Deploy

v0.2.1 Latest version
Use latest version

GitHub Pages Deploy

Deploy static assets to GitHub Pages


Copy and paste the following snippet into your .yml file.

- name: GitHub Pages Deploy
  uses: maxheld83/ghpages@v0.2.1
Learn more about this action in maxheld83/ghpages
Choose a version

GitHub Action to Deploy Static Assets to GitHub Pages

Actions Status View Action

This action simply lets you deploy arbitrary folders of static content from your workflow's working directory (/github/workspace) to GitHub pages. This works by having your action instance git push your chosen asset folder (BUILD_DIR) to the gh-pages branch of your GitHub repository for the gh-pages branch to be served. If you are running this action inside an organization or user repository (named username/ it will deploy to the master branch instead.

Remember to add appropriate filter action as dependencies on this action to avoid deploying from all branches, as well as to avoid "infinite loops" where the deployment itself would trigger another run.

Remember that you may also have to adjust your repository settings.

Because this action deploys to separate, "deploy-only" branches, you can not use it if you want to deploy from a repo subdirectory such as docs/. In those cases you really don't need a GitHub Action, because you would be committing the build artifacts yourself. For details see the GitHub Pages Documentation.

There are already great GitHub actions to use static site generators and then deploy to GitHub Pages (for jekyll, jekyll, zola and surely many more to come). This action isn't that, though I've borrowed much of the git action from these works.

This action will not build anything, it just deploys.


Deployment to GitHub pages happens by git pushing to the gh-pages (or master) branch. To authorise this, the GitHub action needs a secret. For now, somewhat confusingly, the GITHUB_TOKEN available for every repo does suffice to push to gh-pages, but does not suffice to trigger a page build on GitHub, or even propagate the content to the GitHub content-delivery network.

You therefore have to create a custom Personal Access Token (PAT) much like you'd do for external services (say, Travis). You then have to paste this token into the GitHub UI as a secret under the name GH_PAT (repository settings/secrets) and call it in the action as in the below.

I've asked GitHub to streamline this process. The discussion is documented here.

Environment Variables

Just BUILD_DIR, the build directory relative to your repository root. You can also pass . if you want to push your repository root.



Example Usage

action "Deploy to GitHub Pages" {
  uses = "maxheld83/ghpages@v0.2.1"
  env = {
    BUILD_DIR = "public/"
  secrets = ["GH_PAT"]
You can’t perform that action at this time.