From 9802c99e99b69b6e3733f7f72c1a6092d0831e4e Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 11 May 2024 18:04:03 +0800 Subject: [PATCH] :construction_worker: Add ci --- .github/workflows/update.yml | 40 +++++++++++++++++++++++++ compiler/get_character_promotions.py | 26 ++++++++++++++++ compiler/get_relic_config.py | 24 +++++++++++++++ compiler/main.py | 13 ++++++++ src/starrailrelicscore/data/metadata.py | 1 - 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/update.yml create mode 100644 compiler/get_character_promotions.py create mode 100644 compiler/get_relic_config.py create mode 100644 compiler/main.py diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 0000000..32fff11 --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,40 @@ +name: Fetch Res + +on: + workflow_dispatch: ~ + +jobs: + Fetch-Wiki: + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@master + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Install Dependencies + run: | + python -m pip install httpx black + + - name: Fetch Remote Files + run: | + cd compiler + python main.py + cd .. + black . + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + - name: Commit changes + run: | + git add . + git commit -S -m ":bento: Update res" + git push diff --git a/compiler/get_character_promotions.py b/compiler/get_character_promotions.py new file mode 100644 index 0000000..40335ae --- /dev/null +++ b/compiler/get_character_promotions.py @@ -0,0 +1,26 @@ +from httpx import get + +url = "https://raw.githubusercontent.com/fribbels/hsr-optimizer/main/src/data/character_promotions.json" + + +def get_content() -> str: + req = get(url) + return req.text + + +def save_content(content: str) -> None: + with open( + "../src/starrailrelicscore/data/character_promotions.json", + "w", + encoding="utf-8", + ) as file: + file.write(content) + + +def main(): + content = get_content() + save_content(content) + + +if __name__ == "__main__": + main() diff --git a/compiler/get_relic_config.py b/compiler/get_relic_config.py new file mode 100644 index 0000000..a595ab6 --- /dev/null +++ b/compiler/get_relic_config.py @@ -0,0 +1,24 @@ +from httpx import get + +url = "https://raw.githubusercontent.com/PaiGramTeam/HonkaiStarRailWikiDataParser/remote/data/relic_config.json" + + +def get_content() -> str: + req = get(url) + return req.text + + +def save_content(content: str) -> None: + with open( + "../src/starrailrelicscore/data/relic_config.json", "w", encoding="utf-8" + ) as file: + file.write(content) + + +def main(): + content = get_content() + save_content(content) + + +if __name__ == "__main__": + main() diff --git a/compiler/main.py b/compiler/main.py new file mode 100644 index 0000000..7cf91f6 --- /dev/null +++ b/compiler/main.py @@ -0,0 +1,13 @@ +from get_metadata import main as get_metadata +from get_character_promotions import main as get_character_promotions +from get_relic_config import main as get_relic_config + + +def main(): + get_metadata() + get_character_promotions() + get_relic_config() + + +if __name__ == "__main__": + main() diff --git a/src/starrailrelicscore/data/metadata.py b/src/starrailrelicscore/data/metadata.py index 0c4eabf..983ed8d 100644 --- a/src/starrailrelicscore/data/metadata.py +++ b/src/starrailrelicscore/data/metadata.py @@ -4,7 +4,6 @@ METADATA_CH_TYPE = Dict[str, Union[Dict[Parts, List[Stats]], Dict[Stats, float]]] METADATA_TYPE = Dict[int, METADATA_CH_TYPE] - METADATA = { 1001: { # March 7th "stats": {