forked from infra/otc-metadata
finetune repos
This commit is contained in:
parent
0f9f4cf295
commit
a18ca7e2a4
@ -42,6 +42,9 @@ sys.path.insert(0, os.path.abspath('../'))
|
||||
sys.path.insert(0, os.path.abspath('./'))
|
||||
|
||||
# -- General configuration ----------------------------------------------------
|
||||
# https://docutils.sourceforge.io/docs/user/smartquotes.html - it does not
|
||||
# what it is expected
|
||||
smartquotes = False
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
|
||||
|
@ -6,12 +6,20 @@ from ruamel.yaml import YAML
|
||||
data = otc_metadata.services.Services()
|
||||
new_data = data._service_data
|
||||
|
||||
services = data.service_dict
|
||||
#services = data.service_dict
|
||||
|
||||
for srv in new_data["services"]:
|
||||
srv["teams"] = [
|
||||
{"name": f"docs-{srv['service_category']}-rw", "permission": "write"}
|
||||
]
|
||||
for doc in new_data["documents"]:
|
||||
hc_location = None
|
||||
if "type" in doc:
|
||||
if doc["type"] == "api-ref":
|
||||
hc_location = "api"
|
||||
elif doc["type"] == "umn":
|
||||
hc_location = "usermanual"
|
||||
elif doc["type"] == "dev":
|
||||
hc_location = "devg"
|
||||
if hc_location:
|
||||
hc_location += f"/{doc['service_type']}"
|
||||
doc["hc_location"] = hc_location
|
||||
|
||||
|
||||
_yaml = YAML()
|
||||
|
@ -17,6 +17,7 @@ import argparse
|
||||
import logging
|
||||
import os
|
||||
import pathlib
|
||||
import requests
|
||||
import subprocess
|
||||
import warnings
|
||||
|
||||
@ -32,6 +33,8 @@ import otc_metadata.services
|
||||
|
||||
data = otc_metadata.services.Services()
|
||||
|
||||
api_session = requests.Session()
|
||||
|
||||
|
||||
def process_repositories(args, service):
|
||||
"""Checkout repositories
|
||||
@ -119,7 +122,7 @@ def process_repositories(args, service):
|
||||
try:
|
||||
new_branch = repo_to.create_head(branch_name, 'main')
|
||||
except Exception:
|
||||
logging.warn(f"Skipping service {service}")
|
||||
logging.warning(f"Skipping service {service}")
|
||||
return
|
||||
new_branch.checkout()
|
||||
|
||||
@ -160,6 +163,35 @@ def process_repositories(args, service):
|
||||
cwd=copy_to,
|
||||
check=True
|
||||
)
|
||||
elif 'gitea' in url_to and args.token:
|
||||
open_pr(
|
||||
args,
|
||||
repo["repo"],
|
||||
dict(
|
||||
head=branch_name,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def open_pr(args, repository, pr_data):
|
||||
req = dict(
|
||||
base=pr_data.get("base", "main"),
|
||||
head=pr_data["head"],
|
||||
)
|
||||
if "title" in pr_data:
|
||||
req["title"] = pr_data["title"]
|
||||
if "body" in pr_data:
|
||||
req["body"] = pr_data["body"].replace("\\n", "\n")
|
||||
if "assignees" in pr_data:
|
||||
req["assignees"] = pr_data["assignees"]
|
||||
if "labels" in pr_data:
|
||||
req["labels"] = pr_data["labels"]
|
||||
rsp = api_session.post(
|
||||
f"{args.api_url}/repos/{repository}/pulls", json=req
|
||||
)
|
||||
if rsp.status_code != 201:
|
||||
print(rsp.text)
|
||||
print(f"Going to open PR with title {pr_data['title']} in {repository}")
|
||||
|
||||
|
||||
def main():
|
||||
@ -189,7 +221,8 @@ def main():
|
||||
action='store_true',
|
||||
help='Whether to force branch recreation.'
|
||||
)
|
||||
|
||||
parser.add_argument("--token", metavar="token", help="API token")
|
||||
parser.add_argument("--api-url", help="API base url of the Git hoster")
|
||||
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
|
@ -76,6 +76,7 @@ def process_services(args, services):
|
||||
allow_merge_commit=False,
|
||||
allow_squash_merge=True,
|
||||
allow_rebase_merge=False,
|
||||
allow_update_branch=True,
|
||||
branch_protections=[]
|
||||
)
|
||||
|
||||
@ -127,7 +128,7 @@ def process_services(args, services):
|
||||
data = copy.deepcopy(github_repo_template)
|
||||
data["description"] = (
|
||||
f"Open Telekom Cloud {service['service_title']} "
|
||||
f"Service docs"
|
||||
f"docs"
|
||||
)
|
||||
data["branch_protections"].append({"branch": "main",
|
||||
"template": "zuul"})
|
||||
|
Loading…
x
Reference in New Issue
Block a user