Skip to content
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.

ci(PatchMover): 新增補丁移動腳本 #573

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/scripts/pacther_mover.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""Simple Patch mover"""

import os
import sys
import shutil
from loguru import logger
from pathlib import Path

RESOURCEPACK_PATH = Path("pack/assets")

def ci_formatter(ci: bool):
"""
Log message fomater

Parameters:
ci (bool): Check if is ci
"""
if ci:
# pylint: disable=line-too-long
log_format = "<green>{time:YYYY-MM-DD HH:mm:ss}</green>|<level>{level}</level>|<level>{message}</level>"
logger.remove()
logger.add(sys.stderr, format=log_format)
else:
log_format = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | <level>{level: <8}</level> | <cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>"
logger.remove()
logger.add(sys.stderr, format=log_format)
logger.add("loguru.log")

def patch_mover():
"""
Simple patch mover
"""
logger.info("🚩 複製補丁")
logger.info("")
for i in Path("MultiVersions/Patcher").iterdir():
id = i.name
if id.endswith("patch"):
logger.info(f"📂 複製 {id}")
path = Path(f"{RESOURCEPACK_PATH}/{id}/lang")
path.mkdir(parents=True)
shutil.copy(i.joinpath("lang/zh_tw.json"), path)
else:
logger.error(f"⚠️ {id} 不符合資料夾命名規則")
sys.exit(1)

def main():
"""
Main!
"""
ci = os.environ.get("CI")
ci_formatter(ci)
patch_mover()

main()
6 changes: 6 additions & 0 deletions .github/workflows/Reusable-ResourcePacker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ jobs:
matrix_version: ${{ inputs.matrix_version }}
LOGURU_LEVEL: "INFO"

- name: Move Patch
run: |
poetry run python .github/scripts/pacther_mover.py
env:
LOGURU_LEVEL: "INFO"

- name: Copy misc things
run: |
cp MultiVersions/configs/pack.mcmeta pack/
Expand Down
Loading