github-actions[bot] 权限被拒绝

for*_*bat 66 github-api github-actions

我正在使用 mkdocs 为我的项目生成文档,现在我无法将这些文档部署到 Github 页面,它告诉我:

远程:github-actions[bot] 对 XXX.git 的权限被拒绝。致命:无法访问“XXX”:请求的 URL 返回错误:403

这是我的CI配置

还有我的存储库秘密:(这两个GIT_ACTIONS_PUSH都是我个人的访问令牌。)

如果我CI手动启动该过程,将会像这样CI崩溃。

我该如何解决?

小智 88

\n

\xe2\x9a\xa0\xef\xb8\x8f Warning

\n

This answer recommends changing the default permissions for all action workflows to permissive instead of restrictive. From a security standpoint it is highly discouraged to do so. Instead, check the other answers on this Question for more secure alternatives.

\n
\n

Check if "Read and write permissions" are enabled in Settings -> Actions -> General -> Workflow permissions:

\n

工作流程权限设置

\n

  • Github不允许我授予读写权限 (4认同)
  • 默认情况下,回购分支上的工作流程是禁用的,您必须手动启用它们。接得好! (2认同)

小智 19

如果您要创建新文件,则需要授予显式写入权限

permissions:
  contents: write
Run Code Online (Sandbox Code Playgroud)