Gitea actions templates (#57)
All checks were successful
Create Weekly Analytics Stats / run-analytics (push) Successful in 7s

Reviewed-on: #57
Reviewed-by: Tino Schreiber <tino.schreiber@t-systems.com>
Co-authored-by: Sebastian Gode <sebastian.gode@telekom.de>
Co-committed-by: Sebastian Gode <sebastian.gode@telekom.de>
This commit is contained in:
2025-10-01 12:25:56 +00:00
committed by Gode, Sebastian
parent 8c2aa088e9
commit 8500bdb658
3 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,30 @@
name: Build HTML Docs
on:
pull_request:
types: [opened, reopened, synchronize, edited]
jobs:
tox-docs:
runs-on: ubuntu-latest
steps:
- uses: https://github.com/opentelekomcloud-infra/github-actions/.github/actions/tox-run-env@v1
with:
tox-env: docs
- name: Upload documentation preview
uses: https://github.com/opentelekomcloud-infra/github-actions/.github/actions/tox-upload-swift@v1
with:
docs_path: "doc/build/html"
docs_service: {{ service_uri }}
swift_container: "gitea_action_logs"
{% raw -%}
otc_swift_username: ${{ secrets.OTC_SWIFT_USERNAME }}
otc_swift_password: ${{ secrets.OTC_SWIFT_PASSWORD }}
otc_swift_project_name: ${{ secrets.OTC_SWIFT_PROJECT_NAME }}
otc_swift_domain: ${{ secrets.OTC_SWIFT_DOMAIN }}
otc_swift_endpoint: ${{ secrets.OTC_SWIFT_ENDPOINT }}
gitea_token: ${{ secrets.GITEA_TOKEN }}
gitea_server_url: ${{ gitea.server_url }}
repo: ${{ gitea.repository }}
pr_number: ${{ gitea.event.pull_request.number }}
run_id: ${{ gitea.run_id }}
{%- endraw %}

View File

@ -0,0 +1,30 @@
name: Build PDF Docs
on:
pull_request:
types: [opened, reopened, synchronize, edited]
jobs:
tox-pdf-docs:
runs-on: ubuntu-latest
steps:
- uses: https://github.com/opentelekomcloud-infra/github-actions/.github/actions/tox-run-env@v1
with:
tox-env: pdf-docs
- name: Upload documentation preview
uses: https://github.com/opentelekomcloud-infra/github-actions/.github/actions/tox-upload-swift@v1
with:
docs_path: "doc/build/pdf"
docs_service: {{ service_uri }}
swift_container: "gitea_action_logs"
{% raw -%}
otc_swift_username: ${{ secrets.OTC_SWIFT_USERNAME }}
otc_swift_password: ${{ secrets.OTC_SWIFT_PASSWORD }}
otc_swift_project_name: ${{ secrets.OTC_SWIFT_PROJECT_NAME }}
otc_swift_domain: ${{ secrets.OTC_SWIFT_DOMAIN }}
otc_swift_endpoint: ${{ secrets.OTC_SWIFT_ENDPOINT }}
gitea_token: ${{ secrets.GITEA_TOKEN }}
gitea_server_url: ${{ gitea.server_url }}
repo: ${{ gitea.repository }}
pr_number: ${{ gitea.event.pull_request.number }}
run_id: ${{ gitea.run_id }}
{%- endraw %}

View File

@ -54,6 +54,8 @@ def process_repositories(args, service):
zuul_yaml_template = env.get_template("zuul.yaml.j2") zuul_yaml_template = env.get_template("zuul.yaml.j2")
index_sbv_template = env.get_template("index_sbv.rst.j2") index_sbv_template = env.get_template("index_sbv.rst.j2")
doc_requirements_template = env.get_template("doc_requirements.txt.j2") doc_requirements_template = env.get_template("doc_requirements.txt.j2")
actions_yaml_template_html = env.get_template("build-html-docs.yaml.j2")
actions_yaml_template_pdf = env.get_template("build-pdf-docs.yaml.j2")
for repo in service["repositories"]: for repo in service["repositories"]:
if repo["cloud_environments"][0] == args.cloud_environment: if repo["cloud_environments"][0] == args.cloud_environment:
@ -365,6 +367,26 @@ def process_repositories(args, service):
out.write(zuul_yaml_content) out.write(zuul_yaml_content)
repo_to.index.add(["zuul.yaml"]) repo_to.index.add(["zuul.yaml"])
if args.update_actions:
"""Update actions"""
context = dict(docs=[])
context["service_uri"] = service['service_uri']
actions_yaml_content_html = actions_yaml_template_html.render(**context)
actions_yaml_content_pdf = actions_yaml_template_pdf.render(**context)
actions_yaml_content_html_path = pathlib.Path(copy_to, ".gitea", "workflows", "build-html-docs.yaml")
actions_yaml_content_html_path.parent.mkdir(parents=True, exist_ok=True)
actions_yaml_content_pdf_path = pathlib.Path(copy_to, ".gitea", "workflows", "build-pdf-docs.yaml")
actions_yaml_content_pdf_path.parent.mkdir(parents=True, exist_ok=True)
with open(actions_yaml_content_html_path, "w", encoding="utf-8", newline="") as out:
logging.debug(f"Generating {actions_yaml_content_html_path} from template...")
out.write(actions_yaml_content_html)
repo_to.index.add([".gitea/workflows/build-html-docs.yaml"])
with open(actions_yaml_content_pdf_path, "w", encoding="utf-8", newline="") as out:
logging.debug(f"Generating {actions_yaml_content_pdf_path} from template...")
out.write(actions_yaml_content_pdf)
repo_to.index.add([".gitea/workflows/build-pdf-docs.yaml"])
if len(repo_to.index.diff("HEAD")) == 0: if len(repo_to.index.diff("HEAD")) == 0:
# Nothing to commit # Nothing to commit
logging.debug( logging.debug(
@ -464,6 +486,11 @@ def main():
action="store_true", action="store_true",
help="Whether to update zuul.yaml" help="Whether to update zuul.yaml"
) )
parser.add_argument(
"--update-actions",
action="store_true",
help="Whether to update the action yaml files for rendering docs."
)
parser.add_argument( parser.add_argument(
"--overwrite-index-sbv", "--overwrite-index-sbv",
action="store_true", action="store_true",