mirror of
https://github.com/Sliverkiss/QuantumultX.git
synced 2025-12-17 15:24:59 +08:00
Create generate_image_json.py
This commit is contained in:
30
.github/scripts/generate_image_json.py
vendored
Normal file
30
.github/scripts/generate_image_json.py
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import json
|
||||
|
||||
def generate_json():
|
||||
image_folder = 'test'
|
||||
json_data = {
|
||||
"name": "Sakura图标订阅",
|
||||
"description": "收集一些自己脚本用到的图标",
|
||||
"icons": []
|
||||
}
|
||||
|
||||
for filename in os.listdir(image_folder):
|
||||
if filename.endswith(".png"):
|
||||
image_path = os.path.join(image_folder, filename)
|
||||
raw_url = f"https://raw.githubusercontent.com/{os.environ['GITHUB_REPOSITORY']}/main/{image_path}"
|
||||
icon_data = {"name": filename, "url": raw_url}
|
||||
json_data["icons"].append(icon_data)
|
||||
|
||||
# Set the output path relative to the repository root
|
||||
output_path = os.path.join(os.getcwd(), 'test.icons.json')
|
||||
|
||||
with open(output_path, 'w', encoding='utf-8') as json_file:
|
||||
json.dump(json_data, json_file, ensure_ascii=False, indent=2)
|
||||
|
||||
# Save output data to the GITHUB_STATE environment file
|
||||
with open(os.environ['GITHUB_STATE'], 'a') as state_file:
|
||||
state_file.write(f"ICONS_JSON_PATH={output_path}\n")
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_json()
|
||||
Reference in New Issue
Block a user