Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

Commit 1b2e3f1

Browse files
committed
feat: Auto-generate assets.json and enable direct asset URLs
- Add scripts/generate-assets.js to automatically generate assets.json from filesystem, extracting metadata, tags, and sizes from SVG files - Add .github/workflows/update-assets.yml to regenerate assets.json when assets change and commit updates automatically - Update .github/workflows/pages.yml to: - Copy assets to root directories (icons/, logos/, images/) during deployment for direct URL access (e.g., /icons/file.svg) - Add fallback to generate assets.json if missing - Regenerate assets.json with updated script output This enables: - Direct asset access at shorter URLs (https://assets.awsug.nz/icons/file.svg) - Automatic assets.json updates when new files are added - No manual maintenance of assets.json required
1 parent 187c584 commit 1b2e3f1

File tree

4 files changed

+411
-96
lines changed

4 files changed

+411
-96
lines changed

.github/workflows/pages.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ jobs:
2323
steps:
2424
- name: Checkout
2525
uses: actions/checkout@v4
26+
- name: Setup Node.js (for fallback)
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20'
30+
- name: Generate assets.json if missing (fallback)
31+
run: |
32+
if [ ! -f "assets.json" ]; then
33+
echo "assets.json missing, generating as fallback..."
34+
node scripts/generate-assets.js || echo "Generation failed, continuing..."
35+
fi
2636
- name: Create symlinks for direct access
2737
run: |
2838
mkdir -p icons logos images
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Update Assets JSON
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
paths:
7+
- 'assets/**'
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
update-assets:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20'
26+
27+
- name: Generate assets.json
28+
run: |
29+
node scripts/generate-assets.js
30+
31+
- name: Commit and push if changed
32+
run: |
33+
git config --local user.email "action@github.com"
34+
git config --local user.name "GitHub Action"
35+
git add assets.json
36+
if [ -n "$(git status --porcelain)" ]; then
37+
git commit -m "Auto-update: Regenerate assets.json from filesystem"
38+
git push
39+
echo "ASSETS_UPDATED=true" >> $GITHUB_ENV
40+
else
41+
echo "No changes to assets.json"
42+
echo "ASSETS_UPDATED=false" >> $GITHUB_ENV
43+
fi

0 commit comments

Comments
 (0)