GitHub Pages and GitHub Actions

Deploy your static site to GitHub Pages using GitHub Actions

Originally published at github.com

Lastmod: 2020-09-22

View Source Edit
Deploy your static site to GitHub Pages using GitHub Actions

Table of Contents

GitHub Actions for GitHub Pages

GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site with Static Site Generators peaceiris/actions-gh-pages

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, mdBook, MkDocs, Gatsby, GitBook, etc.).

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

The above example step will deploy ./public directory to gh-pages branch.

Example Workflow

Here is an example workflow for Hugo project. Creat YAML file .github/workflows/gh-pages.yml and push to your remote default branch.

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

Deploy to master branch

For <username>.github.io repository.

- name: Deploy
  uses: peaceiris/actions-gh-pages@v3
  with:
    deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
    publish_branch: master
    publish_dir: ./public
comments powered by Disqus

Random Recommended Posts