mirror of
https://github.com/kbenestad/mdcms.git
synced 2026-06-18 15:24:32 +00:00
46 lines
1.4 KiB
YAML
46 lines
1.4 KiB
YAML
name: Update themes index
|
|
|
|
on:
|
|
push:
|
|
branches: [gh-pages]
|
|
paths:
|
|
- 'themes/**'
|
|
- '!themes/index.json'
|
|
|
|
jobs:
|
|
update-index:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: gh-pages
|
|
|
|
- name: Regenerate themes/index.json
|
|
run: |
|
|
python3 - << 'EOF'
|
|
import json, os
|
|
themes_root = 'themes'
|
|
result = {}
|
|
for cat in sorted(os.listdir(themes_root)):
|
|
cat_path = os.path.join(themes_root, cat)
|
|
if not os.path.isdir(cat_path):
|
|
continue
|
|
files = sorted(f for f in os.listdir(cat_path) if f.endswith('.yaml'))
|
|
themes = [{'slug': cat + '/' + f, 'label': f[:-5].replace('-', ' ')} for f in files]
|
|
if themes:
|
|
result[cat] = themes
|
|
with open('themes/index.json', 'w') as fh:
|
|
json.dump(result, fh, indent=2)
|
|
total = sum(len(v) for v in result.values())
|
|
print(f'Updated: {len(result)} categories, {total} themes')
|
|
EOF
|
|
|
|
- name: Commit and push
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add themes/index.json
|
|
git diff --cached --quiet || git commit -m "Auto-update themes/index.json"
|
|
git push
|