Github操作机器人向gh页面推送导致页面构建失败



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

这是完整的脚本,所有的东西都可以找到,包括推送更新,这是通过以下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操作机器人推送到了gh页面分支。

然而,github.io页面没有更新,在我的回购配置中,我看到了消息:

您的网站在生成时出现问题:页面生成失败。

我找不到更多信息或更有用的错误消息。检查分支表明它正确地包含了所有期望的文件,包括.nojekyll。github令牌似乎拥有所有必要的权限,因为它允许推送并具有读/写或部署。

如果我检查出分支并推送具有相同内容的不同提交,那么构建就可以工作:

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范围的个人访问令牌,而不是默认的GITHUB_TOKEN

GitHub支持部门的一封电子邮件证实,GITHUB_TOKEN不起作用是故意的。

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

最新更新