Fix Theme Metadata Duplication and Add Missing Properties for Recent Pull Requests (#575)

* fix ability to add tags multiple times when rebuilding themes

* fix `createdAt` not being added for pull requests made prior

* adds tags property if it doesn't exist (old PRs)

* updated affected `theme.json` files

* updated more affected `theme.json` files

* fix action failing if new commits before finished

* make action only initiate when themes are changed
This commit is contained in:
TheRealMG 2024-10-13 02:59:29 -05:00 committed by GitHub
parent 65c8c1fed0
commit a73edd785e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 53 additions and 14 deletions

View file

@ -1,13 +1,11 @@
name: Update Theme Timestamps name: Update Theme Timestamps
on: on:
pull_request:
branches:
- main
types: [closed]
push: push:
branches: branches:
- main - main
paths:
- 'themes/**'
jobs: jobs:
update-timestamp: update-timestamp:
@ -57,4 +55,5 @@ jobs:
git add "themes/$theme/theme.json" git add "themes/$theme/theme.json"
done done
git commit -m "Update \`updated at\` field for \`$CHANGED_THEMES\`" git commit -m "Update \`updated at\` field for \`$CHANGED_THEMES\`"
git push git pull origin main --strategy-option=theirs
git push origin main

View file

@ -75,11 +75,12 @@ def main():
if "tags" not in theme_data: if "tags" not in theme_data:
theme_data["tags"] = [] theme_data["tags"] = []
# Add 'color theme' tag if colors.json is present # Add 'color theme' tag if colors.json is present and tag isn't already in tags list
theme_data["tags"].append("color theme") if "color scheme" not in theme_data["tags"]:
theme_data["tags"].append("color scheme")
# Add 'dark' tag if colors.json specifies dark mode # Add 'dark' tag if colors.json specifies dark mode and tag isn't already in tags list
if "isDarkMode" in colors and colors["isDarkMode"]: if "isDarkMode" in colors and colors["isDarkMode"] and "dark" not in theme_data["tags"]:
theme_data["tags"].append("dark") theme_data["tags"].append("dark")
themes_data[theme] = theme_data themes_data[theme] = theme_data

View file

@ -22,8 +22,22 @@ def update_theme_date(theme_path):
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
panic("Error reading theme.json: " + str(e)) panic("Error reading theme.json: " + str(e))
# Get the current date
current_date = time.strftime("%Y-%m-%d")
# Set `createdAt` to the current date if it doesn't exist
if "createdAt" not in theme_data:
theme_data["createdAt"] = current_date
print(f"Set `createdAt` for {theme_path} to {theme_data['createdAt']}")
# Update the `updatedAt` field to the current date # Update the `updatedAt` field to the current date
theme_data["updatedAt"] = time.strftime("%Y-%m-%d") theme_data["updatedAt"] = current_date
print(f"Updated `updatedAt` for {theme_path} to {theme_data['updatedAt']}")
# Add `tags` as an empty list if it doesn't exist
if "tags" not in theme_data:
theme_data["tags"] = []
print(f"Initialized `tags` for {theme_path} as an empty list")
# Write the changes back to theme.json # Write the changes back to theme.json
with open(theme_file, "w") as f: with open(theme_file, "w") as f:

View file

@ -7,5 +7,7 @@
"readme": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/253a3a74-0cc4-47b7-8b82-996a64f030d5/readme.md", "readme": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/253a3a74-0cc4-47b7-8b82-996a64f030d5/readme.md",
"image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/253a3a74-0cc4-47b7-8b82-996a64f030d5/image.png", "image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/253a3a74-0cc4-47b7-8b82-996a64f030d5/image.png",
"author": "ahmaadaziz", "author": "ahmaadaziz",
"createdAt": "2024-10-12",
"updatedAt": "2024-10-12",
"version": "1.0.0" "version": "1.0.0"
} }

View file

@ -8,5 +8,7 @@
"image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/4596d8f9-f0b7-4aeb-aa92-851222dc1888/image.png", "image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/4596d8f9-f0b7-4aeb-aa92-851222dc1888/image.png",
"author": "p-sw", "author": "p-sw",
"version": "1.0.0", "version": "1.0.0",
"tags": [],
"createdAt": "2024-10-12",
"updatedAt": "2024-10-12" "updatedAt": "2024-10-12"
} }

View file

@ -10,5 +10,5 @@
"version": "1.0.2", "version": "1.0.2",
"tags": [], "tags": [],
"createdAt": "2024-09-01", "createdAt": "2024-09-01",
"updatedAt": "2024-09-07" "updatedAt": "2024-10-12"
} }

View file

@ -8,5 +8,7 @@
"image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/5c4d7772-d963-4672-ab03-e9d541438881/image.png", "image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/5c4d7772-d963-4672-ab03-e9d541438881/image.png",
"author": "jvabn", "author": "jvabn",
"version": "1.0.0", "version": "1.0.0",
"tags": [],
"createdAt": "2024-10-12",
"updatedAt": "2024-10-12" "updatedAt": "2024-10-12"
} }

View file

@ -15,5 +15,5 @@
"dark" "dark"
], ],
"createdAt": "2024-08-31", "createdAt": "2024-08-31",
"updatedAt": "" "updatedAt": "2024-08-31"
} }

View file

@ -9,5 +9,7 @@
"author": "TheRealMG", "author": "TheRealMG",
"version": "1.0.0", "version": "1.0.0",
"preferences": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/664c54f9-d97d-410b-a479-23dd8a08a628/preferences.json", "preferences": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/664c54f9-d97d-410b-a479-23dd8a08a628/preferences.json",
"tags": [],
"createdAt": "2024-10-12",
"updatedAt": "2024-10-12" "updatedAt": "2024-10-12"
} }

View file

@ -10,5 +10,5 @@
"version": "1.0.2", "version": "1.0.2",
"tags": [], "tags": [],
"createdAt": "2024-09-24", "createdAt": "2024-09-24",
"updatedAt": "2024-09-25" "updatedAt": "2024-10-12"
} }

View file

@ -8,5 +8,7 @@
"image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/7ba20fe1-7286-4b1f-9bf6-39d40bec8ae0/image.png", "image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/7ba20fe1-7286-4b1f-9bf6-39d40bec8ae0/image.png",
"author": "shaeriz", "author": "shaeriz",
"version": "1.0.0", "version": "1.0.0",
"tags": [],
"createdAt": "2024-10-12",
"updatedAt": "2024-10-12" "updatedAt": "2024-10-12"
} }

View file

@ -8,5 +8,7 @@
"image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/bb61b145-6875-4afe-86f2-ab00024459dc/image.png", "image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/bb61b145-6875-4afe-86f2-ab00024459dc/image.png",
"author": "mehalter", "author": "mehalter",
"version": "1.0.0", "version": "1.0.0",
"tags": [],
"createdAt": "2024-10-12",
"updatedAt": "2024-10-12" "updatedAt": "2024-10-12"
} }

View file

@ -1 +1,14 @@
{"id": "f7c71d9a-bce2-420f-ae44-a64bd92975ab", "name": "Better Unloaded Tabs", "description": "Makes unloaded tabs easier to notice by making them greyscale and transparent.", "homepage": "https://github.com/Felkazz/zen-browser-better-unloaded-tabs", "style": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/f7c71d9a-bce2-420f-ae44-a64bd92975ab/chrome.css", "readme": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/f7c71d9a-bce2-420f-ae44-a64bd92975ab/readme.md", "image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/f7c71d9a-bce2-420f-ae44-a64bd92975ab/image.png", "author": "Felkazz", "version": "1.0.1", "updatedAt": "2024-10-12"} {
"id": "f7c71d9a-bce2-420f-ae44-a64bd92975ab",
"name": "Better Unloaded Tabs",
"description": "Makes unloaded tabs easier to notice by making them greyscale and transparent.",
"homepage": "https://github.com/Felkazz/zen-browser-better-unloaded-tabs",
"style": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/f7c71d9a-bce2-420f-ae44-a64bd92975ab/chrome.css",
"readme": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/f7c71d9a-bce2-420f-ae44-a64bd92975ab/readme.md",
"image": "https://raw.githubusercontent.com/zen-browser/theme-store/main/themes/f7c71d9a-bce2-420f-ae44-a64bd92975ab/image.png",
"author": "Felkazz",
"version": "1.0.1",
"tags": [],
"createdAt": "2024-10-12",
"updatedAt": "2024-10-12"
}