feat(gitea): grant the bot team access to the repo
This commit is contained in:
+28
-2
@@ -190,11 +190,37 @@ def gitea(args: argparse.Namespace) -> None:
|
|||||||
})
|
})
|
||||||
print(f"{RENOVATE_FILE}: created")
|
print(f"{RENOVATE_FILE}: created")
|
||||||
|
|
||||||
|
org, name = args.repo.split("/", 1)
|
||||||
|
teams = call("GET", f"/orgs/{org}/teams?limit=50") or []
|
||||||
|
team = next((t for t in teams if t["name"] == "renovate"), None)
|
||||||
|
if team is None:
|
||||||
|
team = call("POST", f"/orgs/{org}/teams", {
|
||||||
|
"name": "renovate",
|
||||||
|
"description": "Renovate bot: write on listed repos only, not the whole org",
|
||||||
|
"includes_all_repositories": False,
|
||||||
|
"permission": "none",
|
||||||
|
"units": ["repo.code", "repo.issues", "repo.pulls"],
|
||||||
|
"units_map": {"repo.code": "write", "repo.issues": "write", "repo.pulls": "write"},
|
||||||
|
"can_create_org_repo": False,
|
||||||
|
})
|
||||||
|
print(f"team renovate in {org}: created")
|
||||||
|
call("PUT", f"/teams/{team['id']}/members/renovate")
|
||||||
|
print("bot renovate: added to the team")
|
||||||
|
members = {m["login"] for m in call("GET", f"/teams/{team['id']}/members?limit=50") or []}
|
||||||
|
if "renovate" not in members:
|
||||||
|
call("PUT", f"/teams/{team['id']}/members/renovate")
|
||||||
|
print("bot renovate: added to the team")
|
||||||
|
repos = {r["name"] for r in call("GET", f"/teams/{team['id']}/repos?limit=50") or []}
|
||||||
|
if name in repos:
|
||||||
|
print(f"team access to {name}: already there")
|
||||||
|
else:
|
||||||
|
call("PUT", f"/teams/{team['id']}/repos/{org}/{name}")
|
||||||
|
print(f"team access to {name}: granted")
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"\nOne thing is still manual, and it does not happen by itself: the repo has\n"
|
"\nOne thing is still manual, and it does not happen by itself: the repo has\n"
|
||||||
"to be added to `repositories` in projects/personal/renovate/renovate-config.js\n"
|
"to be added to `repositories` in projects/personal/renovate/renovate-config.js\n"
|
||||||
"of infra/komodo, and the `renovate` team of its organization needs write\n"
|
"of infra/komodo. Extending the preset subscribes nothing - the bot only visits\n"
|
||||||
"access to it. Extending the preset subscribes nothing - the bot only visits\n"
|
|
||||||
"repos named in that list."
|
"repos named in that list."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user