简体   繁体   中英

GitHub Pages error with workflow file environment variables

Does anyone know how to provide environment variables to a live site on GitHub Pages?

I am trying to deploy my site to GitHub Pages and use environment variables that I have entered in the secrets setting on GitHub but am getting errors with my.yaml workflow file. The site works without the use of a workflow at all but the user needs to enter in the environment variables and I would change it so that is not necessary and the documentation I found on GitHub says that you can do this through the use of workflows so I have tried to implement one but can't seem to figure it out.

Most of this code is taken from other sites that I have commented in the file and show working examples, but I am getting a lot of errors when I try to replicate various examples like:

  • "There was an error initializing the repository: Branch is required."
  • "Failed to download action 'https://api.github.com/repos/spk2dc/github-pages-deploy-action/tarball/releases/v3'. Error Response status code does not indicate success: 404 (Not Found)."
name: Deploy to GitHub Pages
on:
  push:
    branches:
      - master
jobs:
  deploy:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [13.2.0]
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Deploy to production
        uses: JamesIves/github-pages-deploy-action@releases/v3
        env:
          BUILD_PATH: public
          BRANCH: master # The branch the action should deploy to.
          GITHUB_PAGE_NAME: spk2dc.github.io
          PA_TOKEN: ${{ secrets.PA_TOKEN }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_KEY }}
          CLIENT_ID: ${{ secrets.CLIENT_ID }}
          CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
          

###### source: https://github.com/marketplace/actions/deploy-your-app-to-github-pages ######
###### source: https://stackoverflow.com/questions/53648652/how-to-use-environment-variables-in-github-page ######
###### source: https://dev.to/pierresaid/deploy-node-projects-to-github-pages-with-github-actions-4jco ######
###### source: https://github.com/marketplace/actions/deploy-to-github-pages ######

The action you're using to deploy to github pages has documentation that can be found here: https://github.com/marketplace/actions/deploy-to-github-pages (which is also the final link in your code in the post). But it looks like you're trying to use variables it doesn't support.

In the version 3.0 release of github-pages-deploy-action , there were breaking changes. Notably, instead of using env: in your code, you need to use with: , and the only variables that are required for the action are GITHUB_TOKEN , BRANCH , and FOLDER .

Additionally, I'm not sure if you have secrets.GITHUB_TOKEN_KEY defined as your own, but the workflow system provides a token you can use as secrets.GITHUB_TOKEN .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM