mirror of
https://github.com/zen-browser/theme-store.git
synced 2025-07-07 17:05:31 +02:00
chore: Rebuild themes.json after theme submission
This commit is contained in:
parent
039f6cb2cf
commit
b560273840
3 changed files with 62 additions and 0 deletions
35
.github/workflows/submit-pr.yml
vendored
Normal file
35
.github/workflows/submit-pr.yml
vendored
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
submitPR:
|
||||||
|
permissions: write-all
|
||||||
|
name: Rebuild themes after theme submission
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
|
||||||
|
- name: Setup Git
|
||||||
|
run: |
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Rebuild all themes
|
||||||
|
run: |
|
||||||
|
python3 scripts/rebuild-themes.py
|
||||||
|
|
||||||
|
- name: Commit changes
|
||||||
|
run: |
|
||||||
|
git add themes.json
|
||||||
|
git commit -m "Rebuild themes.json after theme submission"
|
||||||
|
git push
|
||||||
|
|
||||||
|
|
27
scripts/rebuild-themes.py
Normal file
27
scripts/rebuild-themes.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
THEMES_FOLDER = './themes'
|
||||||
|
THEMES_DATA_FILE = './themes.json'
|
||||||
|
|
||||||
|
def main():
|
||||||
|
for theme in os.listdir(THEMES_FOLDER):
|
||||||
|
theme_folder = os.path.join(THEMES_FOLDER, theme)
|
||||||
|
if not os.path.isdir(theme_folder):
|
||||||
|
continue
|
||||||
|
theme_data_file = os.path.join(theme_folder, 'theme.json')
|
||||||
|
if not os.path.exists(theme_data_file):
|
||||||
|
continue
|
||||||
|
with open(theme_data_file, 'r') as f:
|
||||||
|
theme_data = json.load(f)
|
||||||
|
with open(THEMES_DATA_FILE, 'r') as f:
|
||||||
|
themes_data = json.load(f)
|
||||||
|
themes_data[theme] = theme_data
|
||||||
|
with open(THEMES_DATA_FILE, 'w') as f:
|
||||||
|
json.dump(themes_data, f, indent=4)
|
||||||
|
print(f"Rebuilt theme: {theme}")
|
||||||
|
print("Rebuilt all themes!")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
0
themes.json
Normal file
0
themes.json
Normal file
Loading…
Add table
Add a link
Reference in a new issue