我有一个简单的github repo,用来存放我的简历内容。我使用hackmyresume来生成index.html。我正在使用Github操作来运行npm构建,它应该将生成的内容发布到gh-pages分支。
我的工作流文件有
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命令是
"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设置和秘密是正确的,但我肯定遗漏了一些小东西。任何帮助都将不胜感激。
发布于 2019-11-12 01:26:30
这是因为您使用了GITHUB_TOKEN变量。由于内置令牌不会触发GitHub页面部署作业,因此会出现open issue with GitHub。这意味着您将看到文件被正确提交,但它们将不可见。
要解决此问题,可以使用GitHub访问令牌。您可以学习如何生成一个here。它需要被正确地定义作用域,这样它才有权限推送到公共存储库。您可以将此标记存储在存储库的Settings > Secrets菜单中(类似于ACCESS_TOKEN),然后在您的配置中引用它,如下所示:
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作业。我希望这对你有帮助!
https://stackoverflow.com/questions/58766278
复制相似问题