Github action not triggering gh-pages upon push

I have a similar workflow/action using GITHUB_TOKEN in a priviate repository. And pushes to gh-pages will be picked up by Github Pages without a problem—but the repo has to be private. When I make it public, the environment does not seem to get updated.

7 Likes

It would be really handy if GitHub Actions can trigger GitHub Pages build using GITHUB_TOKEN.

You can do the “workaround” https://github.com/peaceiris/actions-gh-pages#1-add-ssh-deploy-key using SSH deploy keys, but it’s adding complexity and I’m not sure if this can be automated if you have many GitHub repos.

When you use GITHUB_TOKEN there is nothing to configure - you just create “GitHub Action” and you are done.

Thank you…

3 Likes

It seems to have been established that it is a bug by now. The fact it works as expected with private repositories, like reported by @bryanschuetz and tested by @peaceiris , but not with public repositories is an inconsistency in itself that can not be considered in another way than a bug.

Let’s just hope that the Github team will solve it one day or another ^^

17 Likes

I can confirm that a Private repository does “fix” the issue. It’s still a bit of a weird scenario and the error message really doesn’t help troubleshooting the issue :slight_smile:

3 Likes

I ran into this issue too.

https://github.com/rhysd/github-action-benchmark

While I was developing the action in private repository, it worked fine. But once I published it, deploying gh-pages started to fail.

2 Likes

Finally, GitHub Actions is going to be GA today. Thank you, the GitHub support team and the community. Also, I hope that this issue will be considered after Actions become stable.

2 Likes

As of last week I’m not even able to deloy using an access token anymore. Has something changed? I just end up with Page Build Errorr everytime. 

Edit: This was resolved by changing actions/checkout@master to actions/checkout@v1.

4 Likes

@ethomson Just re-iterating that this is still not working for public repositories, even after the General Availablity. You can push to the gh-pages branch with a GITHUB_TOKEN, but the push does not trigger a GitHub pages deploy.

Doing something else to trigger a deploy (like a manual empty commit) does trigger a deploy with the updated content however.

5 Likes

Seeing this same issue in my public repo. My action is setup on a schedule, so the ‘avoiding recursive actions’ feature should not even apply to this action. Also, I’m using checkout@v2. Action: https://github.com/lightswitch05/php-version-audit/blob/master/.github/workflows/auto-updates.yml

2 Likes

Also experienced this issue. Pushing to public repo with ${{ secrets.GITHUB_TOKEN }} does not trigger a successful github pages build. Manual workaround is to change the branch which github pages is to deploy for a moment and then change it back to the original branch.

2 Likes
- name: Deploy
      uses: peaceiris/actions-gh-pages@v2.8.0
      env:
        ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
        PUBLISH_BRANCH: master
        PUBLISH_DIR: ./public
      with:
        keepFiles: true

I modify my  configuration here , now it is success. You should add  SSH deploy key following this :

https://github.com/marketplace/actions/github-pages-action#1-add-ssh-deploy-key

1 Like

@lovepoem, as commented in https://github.com/actions/checkout/issues/75#issuecomment-568468352, using a deployment key is not a solution, but an (uncomfortable) workaround. The default GITHUB_TOKEN allows to push changes to a branch of the same repo (which can be ‘gh-pages’). The issue is on GitHub’s deployment feature refusing to pick the commits pushed by the bot.

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