mirror of
https://github.com/zen-browser/theme-store.git
synced 2025-07-07 17:05:31 +02:00
chore: Update create-theme workflow to include author information and image in theme submission
This commit is contained in:
parent
20922c7873
commit
367a302e9f
3 changed files with 30 additions and 4 deletions
10
.github/ISSUE_TEMPLATE/create-theme.yml
vendored
10
.github/ISSUE_TEMPLATE/create-theme.yml
vendored
|
@ -24,9 +24,13 @@ body:
|
|||
attributes:
|
||||
label: Homepage
|
||||
description: The URL of the theme's homepage or repository.
|
||||
placeholder: Theme Homepage
|
||||
validations:
|
||||
required: true
|
||||
placeholder: https://github.com/...
|
||||
- type: input
|
||||
id: image
|
||||
attributes:
|
||||
label: Image
|
||||
description: "A URL to an image representing the theme. It can be a temporary image, it will be cloned to the theme library. Note: The image must be a PNG file. E.g. an imgur link."
|
||||
placeholder: https://...
|
||||
- type: textarea
|
||||
id: styles
|
||||
attributes:
|
||||
|
|
4
.github/workflows/create-theme.yml
vendored
4
.github/workflows/create-theme.yml
vendored
|
@ -31,6 +31,7 @@ jobs:
|
|||
echo "THEME_NAME=${{ fromJson(steps.issue-parser.outputs.jsonString)['name'] }}" >> $GITHUB_ENV
|
||||
echo "THEME_DESCRIPTION=${{ fromJson(steps.issue-parser.outputs.jsonString)['description'] }}" >> $GITHUB_ENV
|
||||
echo "THEME_HOMEPAGE=${{ fromJson(steps.issue-parser.outputs.jsonString)['homepage'] }}" >> $GITHUB_ENV
|
||||
echo "THEME_IMAGE=${{ fromJson(steps.issue-parser.outputs.jsonString)['image'] }}" >> $GITHUB_ENV
|
||||
echo "THEME_AUTHOR=${{ github.event.issue.user.login }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Write styles to file
|
||||
|
@ -56,6 +57,7 @@ jobs:
|
|||
--name "${{ env.THEME_NAME }}" \
|
||||
--description "${{ env.THEME_DESCRIPTION }}" \
|
||||
--author "${{ env.THEME_AUTHOR }}" \
|
||||
--image "${{ env.THEME_IMAGE }}" \
|
||||
--homepage "${{ env.THEME_HOMEPAGE }}" 2> error.log
|
||||
|
||||
- name: Export creation output
|
||||
|
@ -103,7 +105,7 @@ jobs:
|
|||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
comment: |
|
||||
# Thank you for your contribution!
|
||||
# Thank you for your contribution! :tada:
|
||||
|
||||
Your theme has been successfully submitted. The maintainers will review it and get back to you soon.
|
||||
|
||||
|
|
|
@ -4,9 +4,12 @@ import argparse
|
|||
import json
|
||||
import uuid
|
||||
import sys
|
||||
import requests
|
||||
import imghdr
|
||||
|
||||
STYLES_FILE = "chrome.css"
|
||||
README_FILE = "readme.md"
|
||||
IMAGE_FILE = "image.png"
|
||||
|
||||
TEMPLATE_STYLES_FILE = "./theme-styles.css"
|
||||
TEMPLATE_README_FILE = "./theme-readme.md"
|
||||
|
@ -51,18 +54,32 @@ def validate_description(description):
|
|||
print("Description must be less than 100 characters.", file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
def download_image(image_url, image_path):
|
||||
response = requests.get(image_url)
|
||||
if response.status_code != 200:
|
||||
print("Image URL is invalid.", file=sys.stderr)
|
||||
exit(1)
|
||||
with open(image_path, 'wb') as f:
|
||||
f.write(response.content)
|
||||
# Check if the image is valid and a PNG
|
||||
if imghdr.what(image_path) != 'png':
|
||||
print("Image must be a PNG.", file=sys.stderr)
|
||||
exit(1)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Submit a theme to the theme repo.')
|
||||
parser.add_argument('--name', type=str, help='The theme to submit.')
|
||||
parser.add_argument('--description', type=str, help='The description of the theme.')
|
||||
parser.add_argument('--homepage', type=str, help='The homepage of the theme.')
|
||||
parser.add_argument('--author', type=str, help='The author of the theme.')
|
||||
parser.add_argument('--image', type=str, help='The image of the theme.')
|
||||
args = parser.parse_args()
|
||||
|
||||
name = args.name
|
||||
description = args.description
|
||||
homepage = args.homepage
|
||||
author = args.author
|
||||
image = args.image
|
||||
|
||||
validate_name(name)
|
||||
validate_description(description)
|
||||
|
@ -85,6 +102,7 @@ Just joking, you can do whatever you want. You're the boss.
|
|||
'homepage': homepage,
|
||||
'style': get_static_asset(theme_id, STYLES_FILE),
|
||||
'readme': get_static_asset(theme_id, README_FILE),
|
||||
'image': get_static_asset(theme_id, IMAGE_FILE),
|
||||
'author': author
|
||||
}
|
||||
|
||||
|
@ -98,6 +116,8 @@ Just joking, you can do whatever you want. You're the boss.
|
|||
with open(f"themes/{theme_id}/{README_FILE}", 'w') as f:
|
||||
f.write(get_readme())
|
||||
|
||||
download_image(image, f"themes/{theme_id}/{IMAGE_FILE}")
|
||||
|
||||
print(f"Theme submitted with ID: {theme_id}")
|
||||
for key, value in theme.items():
|
||||
print(f"\t{key}: {value}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue