简体   繁体   English

GitHub 工作流文件环境变量的页面错误

[英]GitHub Pages error with workflow file environment variables

Does anyone know how to provide environment variables to a live site on GitHub Pages?有谁知道如何为 GitHub 页面上的实时站点提供环境变量?

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.我正在尝试将我的站点部署到 GitHub 页面并使用我在 GitHub 的机密设置中输入的环境变量,但 my.yaml 工作流文件出现错误。 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.该站点完全不使用工作流,但用户需要输入环境变量,我会更改它,这样就没有必要了, 我在 GitHub 上找到的文档说你可以通过使用工作流来做到这一点,所以我试图实现一个,但似乎无法弄清楚。

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)." “未能下载操作'https://api.github.com/repos/spk2dc/github-pages-deploy-action/tarball/releases/v3'。错误响应状态代码不表示成功:404(未找到)。 "
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).您用于部署到 github 页面的操作具有可在此处找到的文档: https://github.com/marketplace/actions/deploy-to-github-pages (这也是您的代码中的最终链接邮政)。 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.github-pages-deploy-action3.0 版本中,发生了重大更改。 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 .值得注意的是,您需要在代码中使用with:而不是使用env: ,并且该操作所需的唯一变量是GITHUB_TOKENBRANCHFOLDER

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 .此外,我不确定您是否将secrets.GITHUB_TOKEN_KEY定义为您自己的,但工作流系统提供了一个可以用作secrets.GITHUB_TOKEN 的令牌

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行工作流时如何屏蔽在 Github 中创建的环境变量? - How to mask environment variables created in Github when running a workflow? 在 GitHub 页面上部署的 Gatsby 站点中使用环境变量 - Using environment variables in Gatsby site deployed on GitHub pages github 动作中的环境变量 - Environment variables in github actions 如何从 Github 工作流访问环境机密? - How to access environment secrets from a Github workflow? 如何从 GitHub 操作中的文件分配环境变量? - How to assign environment variables from a file in GitHub actions? 如何在注入到不在工作流文件夹中的属性文件中的 GitHub 工作流中设置机密 - How to Set a Secret in GitHub Workflow that is Injected into Properties File that is Not in the Workflow Folder 错误:没有此类文件或目录将 env 变量传递到 Github 工作流操作中的工作目录 - Error: No such file or directory passing env variable to working-directory in Github Workflow Actions Inject.env.local 文件或自定义环境变量集以在 Github 中构建纱线 - Inject .env.local file or custom set of environment variables to yarn build in Github Actions 设置环境变量时出错 - Error setting environment variables Visual Studio属性页环境变量 - Visual Studio Property Pages Environment Variables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM