如何将React应用程序部署到GitHub Action中的GitHub页面?
我正在构建一个React应用程序,并且正在尝试通过将其自动部署到GitHub页面来实现某种形式的CI/CD。为此,我正在使用NPM软件包 gh-pages ,但是我正在遇到一个错误:
$ gh-pages -d build
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <runner@fv-az72-309.paxcb4zidlwe3mfrpko3itqnmd.bx.internal.cloudapp.net>) not allowed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.
我如何提供“作者身份”以在github页面工人上进行git?
到目前为止,我已经尝试过的事情:
- 使用默认令牌使用
- 默认令牌/结帐
- 使用我的个人访问令牌,并
- 使用
- 设置git config user.name.name和user.email to我自己和github actions的凭据,我的
工作流文件我的工作流文件如下:
name: Github Pages
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# i've also tried with the default token, and without any token
with:
token: ${{secrets.PAT}}
- uses: actions/setup-node@v2
- name: Deploy
run: |
yarn install
CI=false && yarn deploy
package.json脚本:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
我是反应/JS/NPM的新手,所以让我知道我是否需要提供其他信息。
I'm building a React app, and I'm trying to implement some form of CI/CD by having it automatically deploy to Github Pages whenever I push to the main branch. To accomplish this I am using the npm package gh-pages, but I am running into an error:
$ gh-pages -d build
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <runner@fv-az72-309.paxcb4zidlwe3mfrpko3itqnmd.bx.internal.cloudapp.net>) not allowed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.
How do i provide "Author identity" to git on the Github Pages worker?
Things I've tried so far:
- Not using any token with actions/checkout
- Using the default token with actions/checkout
- Using my personal access token with actions/checkout
- Using actions/github-script to
- Setting git config user.name and user.email to both my own and Github Actions' credentials
My workflow file looks as follows:
name: Github Pages
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# i've also tried with the default token, and without any token
with:
token: ${{secrets.PAT}}
- uses: actions/setup-node@v2
- name: Deploy
run: |
yarn install
CI=false && yarn deploy
package.json scripts:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
I am fairly new to React/js/npm, so let me know if I need to provide additional information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我弄清楚了!似乎这是一个权限问题,但是即使正确使用PAT,我仍然必须设置Git Config变量:
I figured it out! Seems like it was a permissions problem, but even when using the PAT properly, i still had to set the git config variables: