1

I have simple github repo where I host the content of my CV. I use hackmyresume to generate the index.html. I'm using Github Actions to run the npm build and it should publish the generated content to the gh-pages branch.

My workflow file has

on:
push:
    branches:
    - master

jobs:
build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Deploy with github-pages
    uses: JamesIves/github-pages-deploy-action@master
    env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        BASE_BRANCH: master # The branch the action should deploy from.
        BRANCH: gh-pages # The branch the action should deploy to.
        FOLDER: target # The folder the action should deploy.
        BUILD_SCRIPT: npm install && npm run-script build

And the build command is

"build": "hackmyresume BUILD ./src/main/resources/json/fresh/resume.json target/index.html -t compact",

I can see the generated html file getting committed to the github branch

https://github.com/emeraldjava/emeraldjava/blob/gh-pages/index.html

but the gh-page doesn't pick this up? I get a 404 error when i hit

https://emeraldjava.github.io/emeraldjava/

I believe my repo setting and secrets are correct but I must be missing something small. Any help would be appreciated.

emeraldjava
  • 10,894
  • 26
  • 97
  • 170
  • 1
    Have you enabled GitHub pages in the repository settings and selected to deploy the `gh-pages` branch? – peterevans Nov 08 '19 at 12:15
  • Yes - the project settings have 'gh-pages' branch as the source for the github pages. – emeraldjava Nov 08 '19 at 12:18
  • It's deployed at http://emeraldjava.github.io/ – peterevans Nov 08 '19 at 12:26
  • No - that's a different repo : https://github.com/emeraldjava/emeraldjava.github.io – emeraldjava Nov 08 '19 at 12:38
  • 2
    Humm - very odd, from this issue https://stackoverflow.com/questions/20422279/github-pages-are-not-updating?rq=1 . I manually edited the gh-pages index.html file within the github browser editor, all subsequent Action builds seem to publish, even then i delete the gh-pages branch. – emeraldjava Nov 08 '19 at 14:01

1 Answers1

3

This is happening because of your use of the GITHUB_TOKEN variable. There's an open issue with GitHub due to the fact that the built in token doesn't trigger the GitHub Pages deploy job. This means you'll see the files get committed correctly, but they won't be visible.

To get around this you can use a GitHub access token. You can learn how to generate one here. It needs to be correctly scoped so it has permission to push to a public repository. You'd store this token in your repository's Settings > Secrets menu (Call it something like ACCESS_TOKEN), and then reference it in your configuration like so:

on:
push:
    branches:
    - master

jobs:
build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Deploy with github-pages
    uses: JamesIves/github-pages-deploy-action@master
    env:
        ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
        BASE_BRANCH: master # The branch the action should deploy from.
        BRANCH: gh-pages # The branch the action should deploy to.
        FOLDER: target # The folder the action should deploy.
        BUILD_SCRIPT: npm install && npm run-script build

You can find an outline of these variables here. Using an access token will allow the GitHub Pages job to trigger when a new deployment is made. I hope that helps!

James Ives
  • 3,177
  • 3
  • 30
  • 63