[英]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:大部分代码取自我在文件中注释并显示工作示例的其他站点,但是当我尝试复制各种示例时遇到很多错误,例如:
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-action
的3.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_TOKEN
、 BRANCH
和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
.此外,我不确定您是否将secrets.GITHUB_TOKEN_KEY
定义为您自己的,但工作流系统提供了一个可以用作secrets.GITHUB_TOKEN
的令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.