Understanding how to publish site via GitHub Pages

Hello! I have a personal repo and I want deploy this site.

cd.yml:

name: github pages

on:
  push:
    branches:
      - master  # Set a branch to deploy
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
        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: 'latest'
          # extended: true

      - name: Build
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        if: github.ref == 'refs/heads/master'
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./public

config.yml:

baseURL: "https://emilyseville7cfg.github.io/"
languageCode: "en-us"
title: "Emily Grace Seville"
theme: "ananke"
ignoreFiles: ["^static/schemas/.*$"]
enableEmoji: true
markup:
  highlight:
    style: dracula
    lineNumbersInTable: false
cascade:
  featured_image: "/backgrounds/default.jpg"
  omit_header_text: true
Params:
  text_color: "purple"

What am I missing to successfully deploy my site? As I understand:

  • site is being built to public folder
  • this folder contents is pushed to gh-pages
  • gh-pages is used to deploy site

Is it right? Why there is no gh-pages branch created after any new commit?

Now GitHub Actions fails with Action failed with "The process '/usr/bin/git' failed with exit code 128". :thinking:

Hey @EmilySeville7cfg

It looks like you maybe publishing to the same branch.

I received similiar error and finally managed to publish my setup succesfully using a different branch to publish.
Here are some things you can check…

My Github actions

name: CI
on: push
jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - name: Git checkout
        uses: actions/checkout@v2

      - name: Setup hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: "0.98.0"

      - name: Build
        # remove --minify tag if you do not need it
        # docs: https://gohugo.io/hugo-pipes/minification/
        run: hugo --minify

      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          personal_token: ${{ secrets.TOKEN }}
          external_repository: YOUR GITHUB SITE LINK HERE
          publish_dir: ./public
          keep_files: true
          publish_branch: master

Obviously replace YOUR GITHUB SITE LINK HERE above.

Head over to Repository Settings > Environments > Environment secrets > Add a Secret… In my case I added a personal token with the name TOKEN. Your CI looks like it has a name GITHUB_TOKEN. Make sure they match.

Note the publish_branch is set to Master which is actually a different branch to my code. My code resides in “Main” branch. My site is published on “Master” branch.

And finally Repository Settings > Pages > Set Source to Branch Master > /Root`

Trigger another run for your actions and it should proceed.