explaingit

jamesives/github-pages-deploy-action

4,579TypeScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A GitHub Action that automatically publishes a build folder to GitHub Pages on every push, no extra credentials needed, just point it at your output folder and which branch to deploy to.

Mindmap

mindmap
  root((gh-pages-action))
    What it does
      Publishes to GitHub Pages
      Runs on every push
      Handles branch creation
    Configuration
      Output folder setting
      Target branch setting
      Custom commit messages
    Features
      Cross-repo deployment
      GitHub Enterprise support
      Single-commit squash mode
    Tech Stack
      TypeScript
      GitHub Actions
      npm package
    Audience
      Web developers
      Open-source maintainers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Automatically publish your React, Vue, or static site build folder to GitHub Pages every time you push to main.

USE CASE 2

Deploy documentation generated by tools like Docusaurus or MkDocs to a gh-pages branch without any manual steps.

USE CASE 3

Publish a built website from one repo to a separate GitHub Pages repo for organizations that keep source and site apart.

USE CASE 4

Call the same deploy logic from a Node.js script using the npm package outside of GitHub Actions.

Tech stack

TypeScriptGitHub ActionsNode.js

Getting it running

Difficulty · easy Time to first run · 5min

Requires a GitHub repository with GitHub Pages enabled, uses the built-in GITHUB_TOKEN so no extra credentials setup is needed.

License details are in the repository, check the license file before commercial redistribution.

In plain English

This is a GitHub Action, meaning it is a piece of automation that runs inside GitHub's own infrastructure whenever something happens in your repository, such as a new code push. Specifically, this action takes a folder from your repository and publishes it to GitHub Pages, the free static website hosting that GitHub offers to every repository. You point the action at the folder where your built website lives (for example, a folder called "build" that your JavaScript project produces), and it pushes those files to the branch GitHub Pages reads from, typically called "gh-pages". To use it, you add a small configuration file to your repository under a ".github/workflows" folder. The example in the README shows a workflow that checks out your code, runs your build command, and then calls this action with two settings: which branch to deploy to, and which folder to push. The action handles creating that branch if it does not already exist, and it authenticates using GitHub's built-in security token so you do not need to set up separate credentials for a basic deployment. The action supports deploying to a different repository than the one it runs in, which is useful for organizations that keep source code and the published site in separate places. It also works with GitHub Enterprise installations. For teams that want finer control, there are optional settings for custom commit messages, clean deployments that wipe the target branch before deploying, and single-commit mode that squashes the history on the deployment branch. Beyond the GitHub Action itself, the package is also published to npm so developers can call the same deployment logic from their own Node.js scripts or custom actions. The project is written in TypeScript and has both unit tests and integration tests running in CI.

Copy-paste prompts

Prompt 1
Show me a complete GitHub Actions workflow that builds my React app with npm run build and then deploys the build folder to GitHub Pages automatically.
Prompt 2
I keep source code in one repo but want to deploy to a different repo's gh-pages branch, show me how to configure github-pages-deploy-action for cross-repo deployment.
Prompt 3
Help me set up the action with a custom commit message and single-commit mode so my gh-pages branch has a clean history instead of every build commit.
Prompt 4
Write a GitHub Actions workflow that deploys my MkDocs documentation site to GitHub Pages whenever I push a tag starting with v.
Prompt 5
Show me how to use the npm package from github-pages-deploy-action directly in a Node.js script to deploy without using GitHub Actions.
Open on GitHub → Explain another repo

← jamesives on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.