Skip to content

Commit 617ca9e

Browse files
committed
add action
1 parent 229b81b commit 617ca9e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

.github/workflows/generate-png.yml

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Convert SVG to PNG
2+
3+
on:
4+
push:
5+
branches:
6+
- feat/svg-converter
7+
8+
jobs:
9+
convert-svg-to-png:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: Install imagemagick
17+
run: |
18+
sudo apt-get install imagemagick
19+
20+
- name: Convert SVGs to PNGs
21+
run: |
22+
total_files=$(find ./ -type f -name "*.svg" | wc -l)
23+
progress=0
24+
25+
find ./ -type f -name "*.svg" | while IFS= read -r file; do
26+
progress=$((progress + 1))
27+
percentage=$((progress * 100 / total_files))
28+
filled=$((percentage / 2))
29+
unfilled=$((50 - filled))
30+
31+
printf "\rProgress: [%${filled}s%${unfilled}s] %d%%" "$(printf '#%.0s' $(seq 1 $filled))" "$(printf ' %.0s' $(seq 1 $unfilled))" "$percentage"
32+
png_file="${file%.svg} 4k.png"
33+
magick -background none -density 700 "$file" -quality 100 -resize 4000 "$png_file"
34+
done
35+
echo
36+
37+
- name: Commit and Push Converted PNGs
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
run: |
41+
git config --global user.name "github-actions[bot]"
42+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
43+
git add .
44+
git commit -m "Generate PNGs"
45+
git push

0 commit comments

Comments
 (0)