-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e185a1d
commit 273e032
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |