From 423a550303f588d0a83501d02c2cb1a9d8b39808 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:12:15 -0400 Subject: [PATCH] Add wiki update action --- .github/workflows/wiki_update.yml | 21 +++++++++++++++++++++ doc/generated/.gitignore | 1 + scripts/gen-markdown-patchlist.py | 27 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 .github/workflows/wiki_update.yml create mode 100644 doc/generated/.gitignore create mode 100644 scripts/gen-markdown-patchlist.py diff --git a/.github/workflows/wiki_update.yml b/.github/workflows/wiki_update.yml new file mode 100644 index 00000000..f8100801 --- /dev/null +++ b/.github/workflows/wiki_update.yml @@ -0,0 +1,21 @@ +name: update-wiki + +on: + push: + branches: + - '1.**' + +jobs: + wikigen: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - run: python3 scripts/gen-markdown-patchlist.py + - name: Upload generated file to wiki + uses: SwiftDocOrg/github-wiki-publish-action@v1 + with: + path: "doc/generated" + env: + GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.WIKI_TOKEN }} \ No newline at end of file diff --git a/doc/generated/.gitignore b/doc/generated/.gitignore new file mode 100644 index 00000000..dd449725 --- /dev/null +++ b/doc/generated/.gitignore @@ -0,0 +1 @@ +*.md diff --git a/scripts/gen-markdown-patchlist.py b/scripts/gen-markdown-patchlist.py new file mode 100644 index 00000000..bf95acb9 --- /dev/null +++ b/scripts/gen-markdown-patchlist.py @@ -0,0 +1,27 @@ +#!/usr/bin/python3 + +import json +import subprocess +from contextlib import redirect_stdout + +branch_name = subprocess.check_output(['git', 'branch', '--show-current']).decode("utf-8").strip() + +with open('doc/generated/' + branch_name + '-Summary-of-Patches.md', 'w') as output_file: + with redirect_stdout(output_file): + with open('common/src/main/resources/assets/modernfix/lang/en_us.json') as lang_json: + lang_obj = json.loads(lang_json.read()) + option_names = [] + for key, value in lang_obj.items(): + if key.startswith("modernfix.option.mixin."): + option_names.append(key.replace("modernfix.option.", "")) + option_names.sort() + print("# Summary of Patches - " + branch_name) + print() + for option in option_names: + option_description = lang_obj.get("modernfix.option." + option) + option_friendly_name = lang_obj.get("modernfix.option.name." + option) + print(f"# `{option}`") + print() + if option_description is not None: + print(option_description) + print("")