Github action not triggering gh-pages upon push

Yes. Deployment key option is a current workaround better than a personal access token (PAT has too large scope). I hope that GitHub Pages build event can be triggered by GITHUB_TOKEN on a public repository. (GITHUB_TOKEN can trigger the event on a private repository.)

Even the Personal Access Token seems to not trigger the update these days.

5 Likes

Correct, just tried today with my personal token and the push is not trigering the build. I had to request a build manually using the GH API:

- name: Request Github Pages build job
        run: >-
          curl -L -X POST
          -H "Content-Type: application/json"
          -H "Authorization: token ${{ secrets.GH_PAT}}"
          "https://api.github.com/repos/${{ github.repository }}/pages/builds"
2 Likes

@xotl - when you manually used the GH API to request the pages build, which permission(s) did your personal access token require to work?

@bwvolleyball, I used t public_repo scope, but if your repo is a private repo you might need the whole repo scope.

2 Likes

Now, I tested deployment with github_token using the GitHub Pages Action on some public repositories. It looks working well…

I do not know any official announcement of the GitHub starts to support triggering the GitHub Pages build event using GITHUB_TOKEN on public repositories…

3 Likes

Yup, I can confirm on my end that the GITHUB_TOKEN secret works for deploying code on the gh-pages branch.

You can view a relevant commit where I reverted the current token (a PAT) to the GITHUB_TOKEN secret here and the deployment run here.

1 Like

Looks like a Personal Access Token is not required anymore to trigger a page build on a public repository. Everything seems to work for me on several repositories with the built-in GITHUB_TOKEN using https://github.com/crazy-max/ghaction-github-pages :

name: website

on: push

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v1
      -
        name: Build
        run: |
          mkdir public
          cat > public/index.html <<EOL
          <!doctype html>
          <html>
            <head>
              <title>GitHub Pages deployed!</title>
            </head>
            <body>
              <p>GitHub Pages with <strong>${{ github.sha }}</strong> commit ID has been deployed through <a href="https://github.com/marketplace/actions/github-pages">GitHub Pages action</a> successfully.</p>
            </body>
          </html>
          EOL
      -
        name: Deploy
        if: success()
        uses: crazy-max/ghaction-github-pages@v1
        with:
          target_branch: gh-pages
          build_dir: public
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1 Like

To visitors,

This problem has been already fixed about 3 months ago.

Now, the GITHUB_TOKEN works well for deploying to GitHub Pages on public repositories and private repositories.

https://github.com/peaceiris/actions-gh-pages

- uses: peaceiris/actions-gh-pages@v3
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

1 Like