-
Notifications
You must be signed in to change notification settings - Fork 4
61 lines (52 loc) · 2.34 KB
/
icons.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: icons.yml
on:
workflow_dispatch:
push:
branches:
- v2
paths:
- configs/*.json
jobs:
icons:
runs-on: ubuntu-latest
name: 🖼️ Create icons
steps:
- name: 🛠 setup Node.js
uses: actions/setup-node@v4
- name: 📥️ checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
configs
- name: 🍱 install converter
run: npm install -gy svgexport
- name: 🖼️ create icons
run: |
# create output directories
mkdir svg
mkdir png
# set sizes
size=1000
# find configs and print them in a line each
jq -nMr '[inputs | select(.icon) | [(input_filename | gsub("^configs/|.json$"; "")), .icon, .github.user, .github.repo, (.github.branch | if . == "" then "main" else . end)] | join("\n")] | join("\n")' configs/*.json | \
# for each config
while read -r config; read -r icon; read -r user; read -r repo; read -r branch; do
svgname="svg/$config.svg"
pngname="png/$config.png"
branch=${branch:="main"}
moothel="https://raw.githubusercontent.com/$user/$repo/$branch/img/moothel.png"
# write svg to a file
echo "$config"
echo "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 $size $size'>" > "$svgname"
echo " <image x='0' y='0' width='100%' height='100%' preserveAspectRatio='meet' href='$moothel'/>" >> "$svgname"
echo " <rect x='66%' y='66%' width='33%' height='33%' fill='white' opacity='0.5'/>" >> "$svgname"
echo " <image x='66%' y='66%' width='33%' preserveAspectRatio='xMidYMid meet' href='$icon'/>" >> "$svgname"
echo "</svg>" >> "$svgname"
# convert to png
svgexport "$svgname" "$pngname"
done
- name: 📤 upload build
uses: actions/upload-artifact@v4
with:
name: icons
path: png/