Skip to content

Commit

Permalink
Update openscad_build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
masuidrive authored Sep 8, 2023
1 parent 5b4f575 commit 5b121d9
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/openscad_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
paths:
- "**/*.scad"
- ".github/workflows/**/*"

jobs:
build_and_deploy:
Expand All @@ -18,14 +19,16 @@ jobs:
sudo apt-get update
sudo apt-get install -y openscad webp xvfb
- name: Generate STL files and PNG thumbnails
- name: Generate STL files and multiple PNG thumbnails
run: |
xvfb-run -a --server-args="-screen 0 1024x768x24" bash -c '
find . -name "*.scad" | grep -v "^./lib/" | while read scad; do
stl_path="${scad%.scad}.stl"
png_path="${scad%.scad}.png"
openscad -o $stl_path $scad
openscad --render --imgsize=256,256 -o $png_path $scad
for angle in 0 90 180 270; do
png_path="${scad%.scad}_${angle}.png"
openscad --camera=0,0,0,0,0,$angle --render --imgsize=256,256 -o $png_path $scad
done
done
'
Expand All @@ -39,11 +42,25 @@ jobs:
run: |
find . ! -path "./.git/*" ! -name ".git" -type f ! \( -name "*.stl" -o -name "*.webp" \) -delete
- name: Generate index.html
run: |
echo "<!DOCTYPE html><html><head><link href='https://cdn.jsdelivr.net/npm/tailwindcss@2.2.16/dist/tailwind.min.css' rel='stylesheet'></head><body>" > index.html
for dir in $(find . -type d -not -path './.git*'); do
dirName=$(basename $dir)
echo "<h2 class='text-2xl font-bold'>$dirName</h2><div class='grid grid-cols-4 gap-4'>" >> index.html
for webp in $(find $dir -name "*.webp"); do
baseName=$(basename -s .webp $webp)
echo "<img class='w-24 h-24' src='$webp' title='$baseName'>" >> index.html
done
echo "</div>" >> index.html
done
echo "</body></html>" >> index.html
- name: Deploy to GitHub Pages
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<email>@users.noreply.github.com"
git checkout -b gh-pages
git add ./*.stl **/*.stl ./*.webp **/*.webp
git add ./*.stl **/*.stl ./*.webp **/*.webp index.html
git commit -m "Update STL files and WebP thumbnails generated by GitHub Actions"
git push -f origin gh-pages
git push -f origin gh-pages

0 comments on commit 5b121d9

Please sign in to comment.