mirror of
https://github.com/homarr-labs/dashboard-icons.git
synced 2025-08-22 17:54:23 +02:00
feat: add issue_templates for creation of icons (#935)
Co-authored-by: Dashboard Icons Bot <homarr-labs@proton.me>
This commit is contained in:
parent
02aaf9bb7f
commit
d1e008be5f
56 changed files with 18527 additions and 44 deletions
scripts
51
scripts/generate_metadata_file.py
Normal file
51
scripts/generate_metadata_file.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
import json
|
||||
import os
|
||||
import sys
|
||||
from icons import IssueFormType, checkAction, iconFactory, checkType
|
||||
from pathlib import Path
|
||||
|
||||
from metadata import load_metadata
|
||||
|
||||
|
||||
|
||||
ISSUE_FORM_ENV_VAR = "INPUT_ISSUE_FORM"
|
||||
AUTHOR_ID_ENV_VAR = "INPUT_ISSUE_AUTHOR_ID"
|
||||
AUTHOR_LOGIN_ENV_VAR = "INPUT_ISSUE_AUTHOR_LOGIN"
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parent.parent
|
||||
META_DIR = ROOT_DIR / "meta"
|
||||
|
||||
# Ensure the output folders exist
|
||||
META_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def main(type: str, action: IssueFormType, issue_form: str, author_id: int, author_login: str):
|
||||
icon = iconFactory(type, issue_form, action)
|
||||
if (action == IssueFormType.METADATA_UPDATE):
|
||||
existing_metadata = load_metadata(icon.name)
|
||||
author_id = existing_metadata["author"]["id"]
|
||||
author_login = existing_metadata["author"]["login"]
|
||||
metadata = icon.to_metadata({"id": author_id, "login": author_login})
|
||||
|
||||
FILE_PATH = META_DIR / f"{icon.name}.json"
|
||||
|
||||
with open(FILE_PATH, 'w', encoding='UTF-8') as f:
|
||||
json.dump(metadata, f, indent=2)
|
||||
|
||||
|
||||
def parse_author_id():
|
||||
author_id_string = os.getenv(AUTHOR_ID_ENV_VAR)
|
||||
if author_id_string != None:
|
||||
return int(author_id_string)
|
||||
return None
|
||||
|
||||
if (__name__ == "__main__"):
|
||||
type = checkType(sys.argv[1])
|
||||
action = checkAction(sys.argv[2])
|
||||
main(
|
||||
type,
|
||||
action,
|
||||
os.getenv(ISSUE_FORM_ENV_VAR),
|
||||
parse_author_id(),
|
||||
os.getenv(AUTHOR_LOGIN_ENV_VAR)
|
||||
)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue