```AttributeError``` ``在尝试调用回购操作时



我在尝试调用回购及其操作时收到AttributeError的错误消息。

这是我当前的代码:

from github import Github
#Authenticate with GitHub
g = Github("<user>", "<pass>") #Replace <user>, <pass> with your user login and password

#Get the repository
repo = g.get_repo('toughjay318/los-lobos') #Replace 'owner/repo' with the name of your repository

# Determine which actions have permissions set on the repo
actions = repo.get_actions()
if not actions.permissions:
print('No actions have permissions set on the repo')
else:
for action in actions.permissions:
print(f'{action} has permissions set on the repo')
# Determine if pipelines are configured for commits
pipelines = repo.get_workflows()
if not pipelines.totalCount:
print('No pipelines are configured for commits')
else:
print(f'{pipelines.totalCount} pipelines are configured for commits')
# Determine if new branches are configured for actions on commits
branch_protection = repo.get_branch_protection('main') #Replace 'main' with the name of your default branch
if not branch_protection.restrictions:
print('New branches are not configured for actions on commits')
else:
print('New branches are configured for actions on commits')

这是完整的错误信息:

AttributeError                            Traceback (most recent call last)
Input In [20], in <cell line: 12>()
8 repo = g.get_repo('toughjay318/los-lobos') #Replace 'owner/repo' with the name of your repository
11 # Determine which actions have permissions set on the repo
---> 12 actions = repo.get_actions()
14 if not actions.permissions:
15     print('No actions have permissions set on the repo')
AttributeError: 'Repository' object has no attribute 'get_actions'

我试过改变周围的命令,我不知道为什么会发生这个错误。谁能以任何可能的方式帮助我?

如问题1373所示,PyGithub中对GitHub Actions的支持早在2020年1月就提出了。

您可以尝试集成PR 1734("支持工件api")并修改它以查询操作的权限。

相关内容

  • 没有找到相关文章

最新更新