【问题标题】:Github action bot pushing to gh-pages causes page build to failGithub action bot 推送到 gh-pages 导致页面构建失败
【发布时间】:2020-03-13 03:53:56
【问题描述】:

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

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

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 活动提要中看到一条通知,指出 github-actions 机器人已推送到 gh-pages 分支。

但是,github.io 页面没有更新,在我的 repo 配置中我看到了以下消息:

您的网站在构建时遇到问题:页面构建失败。

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

如果我检查分支并推送具有相同内容的不同提交,则构建将起作用:

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 作用域PAT 而不是GITHUB_TOKEN

标签: github github-pages github-actions


【解决方案1】:

我在 cmets 中提出的似乎有效的建议是使用repo 作用域Personal Access Token 而不是默认的GITHUB_TOKEN

来自 GitHub 支持的一封电子邮件证实,GITHUB_TOKEN 不起作用是故意行为。

GitHub Pages 站点构建无法由机器人用户或推送到您的存储库的集成触发。这是为了防止过度使用资源和滥用 GitHub Pages 系统。

【讨论】:

  • github 通过电子邮件确认这是故意的:« GitHub Pages 站点构建无法由机器人用户或推送到您的存储库的集成触发。这是为了防止过度使用资源和滥用 GitHub Pages 系统。 »
  • 很高兴知道!更新了答案。
猜你喜欢
  • 2015-03-12
  • 2017-11-08
  • 2015-06-04
  • 2019-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-02
  • 2017-05-13
相关资源
最近更新 更多