使用github Actions将React应用发布到Github Pages

桑迪普·库玛·辛格

我做了一个简单的Reactjs应用,现在我想在gh页上发布它。我按照此Facebook教程进行了部署,并且也从我的PC上进行了部署。但是现在,我考虑使用Github Actions来部署到master分支的每次推送,而不是每次手动部署它所以我写了下面的动作。

name: gh pages publish

on:
  push:
    branches: master

jobs:
  build:
    runs-on: ubuntu-latest

steps:
  - uses: actions/checkout@v2
  - uses: actions/setup-node@v1
    with:
      node-version: 12
      registry-url: https://registry.npmjs.org/
  - name: publish package
    run: |
      yarn
      npm run deploy

但是此操作失败,因为它要求用户输入用户名和密码。

> gh-pages -d build
fatal: could not read Username for 'https://github.com': No such device or address

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-06-21T07_07_19_700Z-debug.log
##[error]Process completed with exit code 1.

我怎样才能解决这个问题?

编辑:这是package.json文件

    {
  "homepage": "http://itissandeep98.github.io/TimeTableManager/",
  "name": "timetablemanager",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "bootstrap": "^4.5.0",
    "bootstrap-social": "^5.1.1",
    "font-awesome": "^4.7.0",
    "gh-pages": "^3.1.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
哈桑·陶基尔

根据此处的create react app github页面的故障排除,您需要执行以下操作。

  1. 创建一个新的个人访问令牌
  2. git remote set-url origin https://<user>:<token>@github.com/<user>/<repo>
  3. 再试npm run deploy一次

还要确保package.json中的所有内容都是正确的,但这绝对看起来像是身份验证问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

使用gh-pages将React应用发布到github时出现问题

来自分类Dev

如何从Travis CI发布到Github Pages?

来自分类Dev

无法使用octopress部署到Github Pages

来自分类Dev

无法使用octopress部署到Github Pages

来自分类Dev

如何在多个存储库中使用GitHub Actions并部署到GitHub Pages?

来自分类Dev

将React App从Codesandbox部署到Github Pages

来自分类Dev

在GitHub Pages中使用ASP.NET

来自分类Dev

使用 Github Pages 设置多个不同的站点

来自分类Dev

Ruby on Rails与Github Pages

来自分类Dev

在Github Pages上部署

来自分类Dev

来自GitHub Pages的HTTP“发布”请求失败

来自分类Dev

使用Travis CI将Lektor网站部署到Github Pages时出错

来自分类Dev

了解React部署-“将React App部署到Github Pages”教程中到底发生了什么?

来自分类Dev

GitHub Pages:gh-pages分支的结构

来自分类Dev

GitHub Pages:gh-pages分支的结构

来自分类Dev

使用github操作和github-pages-deploy-action时github页面问题?

来自分类Dev

Angular 6 - 将 Angular 6 部署到 Github Pages 错误

来自分类Dev

在Google Chrome中为GitHub Pages使用HTTPS

来自分类Dev

使用GitHub Pages时用于更改目录索引的选项

来自分类Dev

Github Pages-使用Jekyll渲染页面时遇到麻烦

来自分类Dev

我可以在GitHub Pages中使用哪种文件?

来自分类Dev

外部CSS无法与Github Pages一起使用

来自分类Dev

如何使用 GitHub Pages 在 node_modules 下提供文件?

来自分类Dev

如何使用 Octokit 为 repo 打开 Github Pages?

来自分类Dev

GitHub Pages中的分层类别

来自分类Dev

带有GitHub Pages的Favicon

来自分类Dev

GitHub Pages Jekyll无法建立

来自分类Dev

GitHub Pages图片未加载

来自分类Dev

从分叉仓库设置 Github Pages

Related 相关文章

热门标签

归档