actions-gh-pages is a free, open source blogging & personal sites project written in TypeScript and released under MIT. It has 5,362 GitHub stars, 450 forks and 95 open issues, and was last pushed 3 days ago. On this registry it ranks #10 of 25 tracked projects in Blogging & Personal Sites, with 5 head-to-head comparisons available.

What is actions-gh-pages?

What it is

This project is a GitHub Action that deploys static files to GitHub Pages. It lives in the GitHub Actions ecosystem, is written in TypeScript, and is distributed under the MIT license. The action takes a build output directory from a workflow and publishes its contents to a branch that GitHub Pages serves, so a repository can go from committed source to a live site without any manual upload step. It is designed to pair with static site generators rather than to replace them, and the topic list names Hugo, MkDocs, Gatsby, mdBook, Next, Nuxt, and VuePress among the tools it is used alongside.

The concrete problem it solves is the gap between a build step and a published site. A generator produces a directory of HTML, CSS, and assets, but that directory still has to reach a branch that Pages will serve, with the right token, the right branch name, and the right subdirectory layout. This action performs that publish step inside a workflow, so the deployment is repeatable and versioned with the rest of the repository. It also handles the authentication choices that a plain push would require the author to wire up by hand, offering three token modes so that public and private repositories can both be deployed.

Key capabilities

  • Deploys a chosen source directory to GitHub Pages through the publish_dir input, with ./public shown as the example.
  • Supports three authentication methods: github_token, deploy_key, and personal_token, each covering private and public repositories.
  • Publishes to a configurable branch through publish_branch, and can place output in a subdirectory with destination_dir.
  • Filters which assets are published using exclude_assets.
  • Writes a CNAME file for custom domains through the cname input.
  • Can enable the built-in Jekyll processing with enable_jekyll.
  • Runs on Linux, macOS, and Windows runners, and supports GitHub Enterprise Server above version 2.22.6.

Who uses it and how

  • Teams building sites with Hugo, MkDocs, Gatsby, mdBook, Next, Nuxt, or VuePress who want the generated output published on every push.
  • Maintainers of public repositories who use the automatically created GITHUB_TOKEN and need no extra secret configuration.
  • Maintainers of private repositories who supply a deploy_key over SSH or a personal_token over HTTPS.
  • Projects that publish documentation or a site into a subdirectory of an existing Pages branch.
  • Organizations running GitHub Enterprise Server, where a technical user with write permissions may be needed because the runner's token might lack push rights.

Getting started

Add a workflow step that uses peaceiris/actions-gh-pages@v4 with github_token: ${{ secrets.GITHUB_TOKEN }} and publish_dir pointing at the build output. The action is also listed on the GitHub Marketplace.

When to use it — and when not to

The README directs readers to the official GitHub Pages Action first, and notes that GitHub Pages now uses Actions by default, so this action is a reasonable choice mainly when its specific inputs such as destination_dir, exclude_assets, or the deploy key mode are needed. A self-hoster must still configure repository Pages settings, and the first deployment with GITHUB_TOKEN requires manually selecting the publishing branch in the settings tab. Two further limits are visible in the facts: deploy_key support on Windows is marked as work in progress, and on GitHub Enterprise Server the runner token may not carry push privileges.

project readme (upstream, from github) — read inline

GitHub Pages Action

license release GitHub release date Test Code Scanning CodeFactor

[!NOTE]

See also the GitHub official GitHub Pages Action first.

This is a GitHub Action to deploy your static files to GitHub Pages. This deploy action can be combined simply and freely with Static Site Generators. (Hugo, MkDocs, Gatsby, mdBook, Next, Nuxt, and so on.)

The next example step will deploy ./public directory to the remote gh-pages branch.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

For newbies of GitHub Actions: Note that the GITHUB_TOKEN is NOT a personal access token. A GitHub Actions runner automatically creates a GITHUB_TOKEN secret to authenticate in your workflow. So, you can start to deploy immediately without any configuration.

Supported Tokens

Three tokens are supported.

Token Private repo Public repo Protocol Setup
github_token ✅️ ✅️ HTTPS Unnecessary
deploy_key ✅️ ✅️ SSH Necessary
personal_token ✅️ ✅️ HTTPS Necessary

Notes: Actually, the GITHUB_TOKEN works for deploying to GitHub Pages but it has still some limitations. For the first deployment, we need to select the gh-pages branch or another branch on the repository settings tab. See First Deployment with GITHUB_TOKEN

Supported Platforms

All Actions runners: Linux (Ubuntu), macOS, and Windows are supported.

runs-on github_token deploy_key personal_token
ubuntu-22.04 ✅️ ✅️ ✅️
ubuntu-20.04 ✅️ ✅️ ✅️
ubuntu-latest ✅️ ✅️ ✅️
macos-latest ✅️ ✅️ ✅️
windows-latest ✅️ (2) ✅️
  1. WIP, See Issue #87

GitHub Enterprise Server Support

✅️ GitHub Enterprise Server is supported above 2.22.6.

Note that the GITHUB_TOKEN that is created by the runner might not inherently have push/publish privileges on GHES. You might need to create/request a technical user with write permissions to your target repository.

Table of Contents

Getting started

Add your workflow file .github/workflows/gh-pages.yml and push it to your remote default branch.

Here is an example workflow for Hugo.

peaceiris/actions-hugo - GitHub

name: GitHub Pages

on:
  push:
    branches:
      - main  # Set a branch name to trigger deployment
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-22.04
    permissions:
      contents: write
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true  # Fetch Hugo themes (true OR recursive)
          fetch-depth: 0    # Fetch all history for .GitInfo and .Lastmod

      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.110.0'

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v4
        # If you're changing the branch from main,
        # also change the `main` in `refs/heads/main`
        # below accordingly.
        if: github.ref == 'refs/heads/main'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public
Actions log overview GitHub Pages log

Back to TOC ☝️

Options

⭐️ Set Runner's Access Token github_token

This option is for GITHUB_TOKEN, not a personal access token.

A GitHub Actions runner automatically creates a GITHUB_TOKEN secret to use in your workflow. You can use the GITHUB_TOKEN to authenticate in a workflow run.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

For more details about GITHUB_TOKEN: Automatic token authentication - GitHub Docs

⭐️ Set SSH Private Key deploy_key

Read Create SSH Deploy Key, create your SSH deploy key, and set the deploy_key option like the following.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v4
  with:
    deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
    publish_dir: ./public

⭐️ Set Personal Access Token personal_token

Generate a personal access token (repo) and add it to

readme truncated — read the full docs on github

Frequently asked questions

Is actions-gh-pages free to use?

actions-gh-pages is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does actions-gh-pages do?

GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.

What is actions-gh-pages written in?

actions-gh-pages is primarily written in TypeScript. Its source is publicly available at https://github.com/peaceiris/actions-gh-pages, and it has 5,362 GitHub stars.