-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for GitHub repository/organization secrets #1156
Conversation
Adds support for organization and repository secrets. As these are part of the Actions API they are put into a new submodule github3.actions. Currently support OrganizationSecrets and RepositorySecrets. more info on the API at https://developer.github.com/v3/actions/secrets
18b1cbe
to
51a7151
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Hey guys and @sigmavirus24, this PR is open for almost a year. I would be really glad if you could spare some time and give me some review feedback on it. |
src/github3/actions/secrets.py
Outdated
super()._update_attributes(secret) | ||
self.visibility = secret["visibility"] | ||
if self.visibility == "selected": | ||
self._selected_repos_url = secret["selected_repositories_url"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the URL attribute "private"? It should be public and named identically to the value in the JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I made it public and renamed it to selected_repositories_url
.
src/github3/actions/secrets.py
Outdated
list_key="repositories", | ||
) | ||
|
||
def set_selected_repositories(self, repository_ids: typing.List[int]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer Sequence
over List
as a List[int]
precludes Tuple[int]
or any other sequence like data that Python will happily correctly serialize to a JSON Array
src/github3/actions/secrets.py
Outdated
url = "/".join([self._selected_repos_url, str(repository_id)]) | ||
return self._boolean(self._put(url), 204, 409) | ||
|
||
def delete_selected_repository(self, repository_id: int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def delete_selected_repository(self, repository_id: int): | |
def remove_selected_repository(self, repository_id: int): |
Alternatively
These should be:
select_repositories
select_repository
deselect_repository
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the method to remove_selected_repositories()
but would prefer to keep the other function names are they are to be consistent with the GitHub API documentation.
Adds support for organization and repository secrets. As these are part of the GitHub Actions API they are put into a new submodule
github3.actions
.This PR does not support environment secrets as I believe this would better live in a dedicated Environment module.
This PR would potentially fix issue #1024.