Do I need the pages-build-deployment Github Action, when I have another action for my Github Pages?
Asked Answered
K

2

11

In the settings I've enabled Github Pages:

Settings

I have a Github Action which builds and deploy the page to the branch gh-pages.

name: Continuous Deployment

on:
  push:
    branches:
      - master
  schedule:
    - cron: '0 0 * * *'

jobs:
  build-and-deploy:
    name: Build and deploy to Github Pages
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repo
        uses: actions/checkout@v3
      - name: Use nodejs
        uses: actions/setup-node@v3
        with:
          node-version: '16.x'
      - name: Get yarn cache directory path
        id: yarn-cache-dir-path
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - name: Activate dependency cache
        uses: actions/cache@v3
        id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
        with:
          path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Install dependencies
        run: yarn install --frozen-lockfile
      - name: Caching Gatsby
        id: gatsby-cache-build
        uses: actions/cache@v3
        with:
          path: |
            public
            .cache
          key: ${{ runner.os }}-gatsby-build-cache-${{ github.run_id }}
          restore-keys: |
            ${{ runner.os }}-gatsby-build-cache-
      - name: Build website
        run: yarn build:with-prefix
        env:
          PATH_PREFIX: '/xyz'
          SITE_URL: 'https://xyz.github.io/xyz'
          CI: true
      - name: Deploy to GitHub Pages
        uses: JamesIves/[email protected]
        with:
          branch: gh-pages
          folder: public
          clean: true

Now there is another Github Action which seem to deploy my page to Github Actions (using Jakyll):

Github Actions

Now I have two questions, which I couldn't answer by searching the internet:

  1. Do I need this other action pages-build-deployment?
  2. If not, how can I disable it?
  3. If yes, for what it's needed? Am I doing the same work twice?
Ked answered 1/5, 2022 at 19:43 Comment(2)
3. If yes, am I doing the same work twice (build and deploy)? \n I have the same question as you.Gyromagnetic
I tried disabling it, but it re-enabled itself again on new push.Gyromagnetic
I
8

Do I need this other action pages-build-deployment?

This is provided by GitHub automatically.
As discussed in JamesIves/github-pages-deploy-action #1073:

I think there's a lot of scope for confusion for users of this action, when pages build and deployment will also be running on every push and pushing pages assets.

I think it's impossible to really say right now what that looks like until GitHub announces what these actions intend to do in the long run.

As the post suggests, this is a necessary step that occurs after the push gets made, this was already occurring behind the scenes it just wasn't made visible.

So you can ignore it (and there is no obvious way to disable it).
As for doing the same work twice, the same post adds:

What used to happen is, behind the scenes, we used the github-pages[bot] to pull that branch down and deploy the content to the github-pages environment we create for you automatically.

Now this step happens transparently with this new Actions workflow.

The end goal we’re working on is, if you’d prefer to deploy to the pages environment directly (without committing the content to a gh-pages branch), you’ll be able to do that in your own workflow. This will remove the need for the second workflow that we trigger when you commit to the pages branch.

Context: Dec. 2021 "GitHub Pages: using GitHub Actions for builds and deployments for public repositories".

The initial benefit of this change is enabling you to see your build logs and any errors that may occur which has been a long standing issue for Pages users.

However, in the future this will enable us to give you the ability to fully customize your pages build and deployment workflow to use any static site generator you want without having to push the build output to a special branch of the repository.

Idiographic answered 24/6, 2022 at 12:14 Comment(0)
B
6

Now you can go to your GitHub repository's setting page, and go to the "Pages". Then change the "Source" of "Build and deployment" to GitHub Actions. After that, the annoying pages-build-deployment workflow will no longer be auto-triggered.

github repo setting page

Bitolj answered 23/5, 2023 at 17:1 Comment(1)
This seems like the right fix, but have others had luck with it? In my repo, GH doesn't give me any other options besides in that dropdown besides "Deploy from a branch". Is there some other setting I'm missing?Mir

© 2022 - 2024 — McMap. All rights reserved.