Skip to content
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

Merged
merged 8 commits into from
May 16, 2024

Conversation

MrBatschner
Copy link
Contributor

@MrBatschner MrBatschner commented Jun 21, 2023

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.

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
@MrBatschner MrBatschner changed the title Add support for GitHub secrets. Add support for GitHub repository/organization secrets Jun 22, 2023
@MrBatschner
Copy link
Contributor Author

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 Show resolved Hide resolved
super()._update_attributes(secret)
self.visibility = secret["visibility"]
if self.visibility == "selected":
self._selected_repos_url = secret["selected_repositories_url"]
Copy link
Owner

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.

Copy link
Contributor Author

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.

list_key="repositories",
)

def set_selected_repositories(self, repository_ids: typing.List[int]):
Copy link
Owner

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

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):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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.

@MrBatschner MrBatschner requested a review from sigmavirus24 May 15, 2024 07:31
@sigmavirus24 sigmavirus24 merged commit fc040b9 into sigmavirus24:main May 16, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants