Skip to content

add git and gh helper classes#17

Merged
The-Pavel merged 110 commits intomainfrom
git-repos
Nov 28, 2022
Merged

add git and gh helper classes#17
The-Pavel merged 110 commits intomainfrom
git-repos

Conversation

@gmanchon
Copy link
Copy Markdown
Contributor

@gmanchon gmanchon commented Nov 16, 2022

  • Adds GitRepo, GhOrg, GhOrgSecret and GhRepo helper classes
  • Adds tests for the GhRepo class
  • Adds subblack, subred, subgreen, subyellow, subblue, submagenta, subcyan, and subwhite helpers for colorama
  • Updates GitHubRepo constructor params (username removed)

requires #15
required by https://github.com/lewagon/utils/pull/82

@gmanchon gmanchon changed the base branch from main to colorama November 16, 2022 08:19
Base automatically changed from colorama to main November 25, 2022 14:40
@gmanchon gmanchon requested a review from The-Pavel November 25, 2022 14:44
Comment thread doc/drafts/gh_repo.py
Comment on lines +17 to +22
required gh token scopes:
- repo: push commits TBC
- admin:org: create repos TBC
- workflow: push commits containing `.github/workflows/*.yml` files
- delete_repo: delete `lewagon-test` and `lewagon-qa` repositories
"""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

❔ To make sure I understood correctly, so the GH_API_DELETE_TOKEN should have all these rights?

Copy link
Copy Markdown
Contributor Author

@gmanchon gmanchon Nov 28, 2022

Choose a reason for hiding this comment

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

@The-Pavel the scopes of the tokens we agreed on for the moment are described in this doc

in the myriad test gha you can see that GH_API_DELETE_TOKEN is a specific env var used by the myriad code in order to retrieve the AUTOBOT_QA_ADMIN_TOKEN secret containing a token which corresponds to this quite powerful scope (but only works on the QA org)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so at the moment the tokens described by the doc are only used in GHA through a mapping to env vars used by the command lines or script code of the GHA

Copy link
Copy Markdown
Contributor Author

@gmanchon gmanchon Nov 28, 2022

Choose a reason for hiding this comment

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

the tokens exist in the lewagon-test and lewagon-qa orgs, so you can map them to your GHA when you need to test something, and their scope should correspond to the one of the secret with the same name in the lewagon org

there might remain some diffs in the token scopes and token user membership in the lewagon org, but we are trying to figure them out, and the ghadmin tool will help get rid of the differences

Copy link
Copy Markdown

@The-Pavel The-Pavel left a comment

Choose a reason for hiding this comment

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

LGTM @gmanchon ! 🙌

Works as expected locally.

P.S. you are right, I also can't find an API to list secrets in PyGithub, but it has methods for creating and updating secrets, and it's just a wrapper around GH API, maybe in the future we can even contribute our own method to read secrets if we choose to use it 🙌

As for GhRepo class, I think for that we can consider PyGithub in the future.

@The-Pavel The-Pavel merged commit 25f7635 into main Nov 28, 2022
@gmanchon
Copy link
Copy Markdown
Contributor Author

it would be so cool to use it and contribute 🔥

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