Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

GitHub Pages deployment error: "You have to provide a GITHUB_TOKEN or GH_PAT"

I have a simple Node JS application built in the build directory using yarn and trying to deploy on GitHub Pages using GitHub Actions using crazy-max/ghaction-github-pages@v2 actinon in the simplest form:

- name: Deploy
  uses: crazy-max/ghaction-github-pages@v2
  with:
    target_branch: master
    build_dir: build
  env:
    $GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

(Note I deploy to master because the repository name is equal to the <<username>>.github.io)

To my surprise, it fails on the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Error: You have to provide a GITHUB_TOKEN or GH_PAT

The whole message is not helpful as long as I know the GITHUB_TOKEN is automatically generated with each build.

The repository has the following settings under Action:

  • Actions permissions: Allow all actions
  • Fork pull request workflows from outside collaborators: Require approval for first-time contributors
  • Workflow permissions: Read and write permissions

The whole token and permissions management in GitHub is overkill for simple projects and the documentation lacks sample settings and the reader only goes down the rabbit hole.

How to get this run?

>Solution :

Based on the documentation I’m reading, it looks like you need to remove the leading $ from your environment variable name you are setting

Like this:

  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Documenation:

https://github.com/crazy-max/ghaction-github-pages

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading