首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用github操作和github- pages -deploy-action时github pages问题?

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

Stack Overflow用户
提问于 2019-11-08 20:05:45
回答 1查看 572关注 0票数 1

我有一个简单的github repo,用来存放我的简历内容。我使用hackmyresume来生成index.html。我正在使用Github操作来运行npm构建,它应该将生成的内容发布到gh-pages分支。

我的工作流文件有

代码语言:javascript
复制
on:
push:
    branches:
    - master

jobs:
build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Deploy with github-pages
    uses: JamesIves/github-pages-deploy-action@master
    env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        BASE_BRANCH: master # The branch the action should deploy from.
        BRANCH: gh-pages # The branch the action should deploy to.
        FOLDER: target # The folder the action should deploy.
        BUILD_SCRIPT: npm install && npm run-script build

而build命令是

代码语言:javascript
复制
"build": "hackmyresume BUILD ./src/main/resources/json/fresh/resume.json target/index.html -t compact",

我可以看到生成的html文件被提交到github分支。

https://github.com/emeraldjava/emeraldjava/blob/gh-pages/index.html

但是“纽约时报”不会接受这个吗?当我点击时,我得到了一个404错误

https://emeraldjava.github.io/emeraldjava/

我相信我的repo设置和秘密是正确的,但我肯定遗漏了一些小东西。任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-12 01:26:30

这是因为您使用了GITHUB_TOKEN变量。由于内置令牌不会触发GitHub页面部署作业,因此会出现open issue with GitHub。这意味着您将看到文件被正确提交,但它们将不可见。

要解决此问题,可以使用GitHub访问令牌。您可以学习如何生成一个here。它需要被正确地定义作用域,这样它才有权限推送到公共存储库。您可以将此标记存储在存储库的Settings > Secrets菜单中(类似于ACCESS_TOKEN),然后在您的配置中引用它,如下所示:

代码语言:javascript
复制
on:
push:
    branches:
    - master

jobs:
build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Deploy with github-pages
    uses: JamesIves/github-pages-deploy-action@master
    env:
        ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
        BASE_BRANCH: master # The branch the action should deploy from.
        BRANCH: gh-pages # The branch the action should deploy to.
        FOLDER: target # The folder the action should deploy.
        BUILD_SCRIPT: npm install && npm run-script build

您可以找到这些变量的概要here。使用访问令牌将允许在进行新部署时触发GitHub Pages作业。我希望这对你有帮助!

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58766278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档