Github 推送到 gh-pages 的动作机器人导致页面构建失败

Github action bot pushing to gh-pages causes page build to fail

我有一个 github 存储库,我在其中设置了 github 操作来自动构建文档并将其推送到 gh-pages 分支。

Here is the full script,一切都会找到,包括推送更新,这是通过以下两行完成的:

git -c user.email=<hidden from question> -c user.name="${GITHUB_ACTOR}" commit -m "Github Action-built docs update"
git push "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git" HEAD:gh-pages

分支已正确更新,我在 github activity 提要中看到一条通知,表明 github-actions 机器人已推送到 gh-pages 分支。

但是,github.io 页面没有更新,在我的存储库配置中我看到消息:

Your site is having problems building: Page build failed.

我找不到更多信息或更有用的错误消息。检查分支显示它正确包含所有预期的文件,包括 .nojekyllgithub token 似乎拥有所有必要的权限,因为它允许推送并具有 read/write 或部署。

如果我签出分支并推送具有相同内容的不同提交,则构建工作:

git clone -b gh-pages https://github.com/Cimbali/pympress ./pages
cd pages
git commit --amend --no-edit
git push -f

那么为什么会这样呢?我该如何解决?


我已经设法从 github API 获取页面构建。这是失败的构建:

{
  "url": "https://api.github.com/repos/Cimbali/pympress/pages/builds/152994257",
  "status": "errored",
  "error": {
    "message": "Page build failed."
  },
  "pusher": {
    "login": "github-actions[bot]",
    "id": <some integer>,
    "node_id": "<some base 64 value>",
    "avatar_url": "https://avatars2.githubusercontent.com/in/15368?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/github-actions%5Bbot%5D",
    <[...]>
    "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
    "type": "Bot",
    "site_admin": false
  },
  "commit": null,
  "duration": 29,
  "created_at": "2019-11-17T16:55:03Z",
  "updated_at": "2019-11-17T16:55:03Z"
}

这里是为了比较随后的(手动触发的)成功构建:

{
  "url": "https://api.github.com/repos/Cimbali/pympress/pages/builds/152998876",
  "status": "built",
  "error": {
    "message": null
  },
  "pusher": {
    "login": "Cimbali",
    "id": <some integer>,
    "node_id": "<a different base 64 value>",
    "avatar_url": "https://avatars2.githubusercontent.com/u/6126377?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/Cimbali",
    <[...]>
    "received_events_url": "https://api.github.com/users/Cimbali/received_events",
    "type": "User",
    "site_admin": false
  },
  "commit": "b87d18729c945002566bae920361b2bd6bc43be6",
  "duration": 10306,
  "created_at": "2019-11-17T17:46:09Z",
  "updated_at": "2019-11-17T17:46:20Z"
}

我在评论中提出的似乎有效的建议是使用 repo 范围的 Personal Access Token 而不是默认的 GITHUB_TOKEN.

一封来自 GitHub 支持人员的电子邮件确认 GITHUB_TOKEN 不起作用是故意行为。

GitHub Pages site builds aren’t able to be triggered by bot users or integrations that push to your repository. This is to prevent excessive resource usage and abuse of GitHub Pages systems.