1

I am receiving an error message of AttributeError when attempting to call a repo and its actions.

This is my current code:

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')

This is the full errror message:

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'

I have tried changing the commands around and I cannot figure out why this error is happening. Could anyone please assist me in anyway possible?

Jayy Griff
  • 19
  • 3
  • 2
    There's literally no method called `get_actions` -- what makes you think this should work? See all [valid methods here](https://pygithub.readthedocs.io/en/latest/github_objects/Repository.html). – sytech Apr 11 '23 at 02:21
  • 1
    Yeah, that method seems to not exist. Did you copy it from some example somewhere, or did you just make it up? – John Gordon Apr 11 '23 at 02:22

1 Answers1

0

As illustrated by issue 1373, support for GitHub Actions in PyGithub is requested as far back as Jan. 2020.

You could try and integrate PR 1734 ("Support for artifacts API") and modify it to query permissions on actions.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250