All Projects → enriikke → Gatsby Gh Pages Action

enriikke / Gatsby Gh Pages Action

Licence: mit
GitHub Action to build and deploy your Gatsby site to GitHub Pages ❤️🎩

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Gatsby Gh Pages Action

Actions Gh Pages
GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.
Stars: ✭ 2,576 (+1138.46%)
Mutual labels:  gatsby, github-pages
chandrikadeb7.github.io
Personal portfolio website hosted using GitHub Pages - Version 2
Stars: ✭ 99 (-52.4%)
Mutual labels:  github-pages, gatsby
Gatsby Starter Rocket Docs
The documentation starter you were looking for (ready for Gatsby v3) ⚡️
Stars: ✭ 182 (-12.5%)
Mutual labels:  gatsby
Slate
Slate is a Jekyll theme for GitHub Pages
Stars: ✭ 195 (-6.25%)
Mutual labels:  github-pages
Gatsby Starter Morning Dew
🚀 A Gatsby theme/starter to build lightning-fast blog/websites
Stars: ✭ 186 (-10.58%)
Mutual labels:  gatsby
Fast template
A template for really easy blogging with GitHub Pages
Stars: ✭ 184 (-11.54%)
Mutual labels:  github-pages
Js Docs
Este projeto foi desenvolvido para contribuir com o open-source. Se você quiser contribuir basta seguir o README
Stars: ✭ 191 (-8.17%)
Mutual labels:  gatsby
Blog
a blog demo on github pages
Stars: ✭ 179 (-13.94%)
Mutual labels:  github-pages
Fastpages
An easy to use blogging platform, with enhanced support for Jupyter Notebooks.
Stars: ✭ 2,888 (+1288.46%)
Mutual labels:  github-pages
Gportfolio
Creating an automatic portfolio based on Github profile, with the ability to connect others
Stars: ✭ 186 (-10.58%)
Mutual labels:  github-pages
React Portfolio Template
Modern React Portfolio Template (FREE)
Stars: ✭ 188 (-9.62%)
Mutual labels:  gatsby
Gatsby Plugin S3
Deploy your gatsby site to a S3 bucket.
Stars: ✭ 186 (-10.58%)
Mutual labels:  gatsby
Gatsby Docker
Develop & Build GatsbyJS static sites within Docker.
Stars: ✭ 184 (-11.54%)
Mutual labels:  gatsby
Mm Github Pages Starter
Minimal Mistakes GitHub Pages site starter
Stars: ✭ 191 (-8.17%)
Mutual labels:  github-pages
Architect
Architect is a Jekyll theme for GitHub Pages
Stars: ✭ 182 (-12.5%)
Mutual labels:  github-pages
Midway
Headless Starter with Sanity + Gatsby + Shopify Repo
Stars: ✭ 195 (-6.25%)
Mutual labels:  gatsby
Startup Landing
Collection of free top of the line startup landing templates built using react/nextjs/gatsby. Free to download, simply edit and deploy! Updated weekly!
Stars: ✭ 176 (-15.38%)
Mutual labels:  gatsby
Smakosh.com
My personal website
Stars: ✭ 185 (-11.06%)
Mutual labels:  gatsby
Jekyll Remote Theme
Jekyll plugin for building Jekyll sites with any GitHub-hosted theme
Stars: ✭ 188 (-9.62%)
Mutual labels:  github-pages
Remark Codesandbox
🎩 Create CodeSandbox directly from code blocks
Stars: ✭ 204 (-1.92%)
Mutual labels:  gatsby

Gatsby Publish

GitHub Action to build and deploy your Gatsby site to GitHub Pages ❤️🎩

Usage

This GitHub Action will run gatsby build at the root of your repository and deploy it to GitHub Pages for you! Here's a basic workflow example:

name: Gatsby Publish

on:
  push:
    branches:
      - dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: enriikke/[email protected]
        with:
          access-token: ${{ secrets.ACCESS_TOKEN }}

NOTE: In order to support npm and yarn, this Action relies on having a build script defined in your package.json file. Gatsby automatically defines this script whenever you start a new project via gatsby new, which in turn calls gatsby build.

Knobs & Handles

This Action is fairly simple but it does provide you with a couple of configuration options:

  • access-token: A GitHub Personal Access Token with the repo scope. This is required to push the site to your repo after Gatsby finish building it. You should store this as a secret in your repository. Provided as an input.

  • deploy-branch: The branch expected by GitHub to have the static files needed for your site. For org and user pages it should always be master. This is where the output of gatsby build will be pushed to. Provided as an input. Defaults to master.

  • deploy-repo: The repository expected by GitHub to have the static files needed for your site. Provided as an input. Defaults to the same repository that runs this action.

  • gatsby-args: Additional arguments that get passed to gatsby build. See the Gatsby documentation for a list of allowed options. Provided as an input. Defaults to nothing.

  • skip-publish: Builds your Gatsby site but skips publishing by setting it to true, effectively performing a test of the build process using the live configuration. Provided as an input Defaults to false

  • working-dir: The directory where your Gatsby source files are at. gatsby build will run from this directory. Provided as an input Defaults to the project's root.

Org or User Pages

Create a repository with the format <YOUR/ORG USERNAME>.github.io, push your Gatsby source code to a branch other than master and add this GitHub Action to your workflow! 🚀😃

Repository Pages

Repo pages give you the option to push your static site to either master or gh-pages branches. They also work a little different because the URL includes a trailing path with the repository name, like https://username.github.io/reponame/. You need to tell Gatsby what the path prefix is via gatsby-config.js:

module.exports = {
  pathPrefix: "/reponame",
}

Additionally, you need to tell the gatsby build command to use it by passing the --prefix-paths as an argument. Here's an example workflow for that:

name: Gatsby Publish

on:
  push:
    branches:
      - dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: enriikke/[email protected]
        with:
          access-token: ${{ secrets.ACCESS_TOKEN }}
          deploy-branch: gh-pages
          gatsby-args: --prefix-paths

Provides build validation on pull request if required:

name: Gatsby Publish

on:
  pull_request:
    branches:
      - dev

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - uses: enriikke/[email protected]
        with:
          access-token: ${{ secrets.ACCESS_TOKEN }}
          deploy-branch: gh-pages
          gatsby-args: --prefix-paths
          skip-publish: true

CNAME

You have a custom domain you would like to use? Fancy! 😎 This Action's got you covered! Assuming you have already set up your DNS provider as defined in the GitHub Pages docs, all we need next is a CNAME file at the root of your project with the domain you would like to use. For example:

imenrique.com

Notice that it's all capitals CNAME 😊.

This is how GitHub keeps track of the domain you want to use. This action will copy the file to the public directory generated by Gatsby before pushing your site so that the domain is persisted between deploys.

Assumptions

This Action assumes that your Gatsby code sits at the root of your repository and gatsby build outputs to the public directory. As of this writing, Gatsby doesn't provide a way to customize the build directory so this should be a safe assumption.

Additionally, a build script on package.json is expected for this Action to to work (as mentioned at the beginning). Ultimately, this is what calls gatsby build.

That's It

Have fun building! ✨

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].