diff --git a/.github/workflows/openscad_build.yml b/.github/workflows/openscad_build.yml index 498ee86..e8a01d2 100644 --- a/.github/workflows/openscad_build.yml +++ b/.github/workflows/openscad_build.yml @@ -1,4 +1,4 @@ -name: Generate and Deploy OpenSCAD preview to GitHub Pages +name: Generate STL and WebP Thumbnails using OpenSCAD on: push: @@ -13,21 +13,35 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Install OpenSCAD - run: sudo apt-get install -y openscad + - name: Install OpenSCAD and WebP tools + run: | + sudo apt-get update + sudo apt-get install -y openscad webp - - name: Generate STL files + - name: Generate STL files and PNG thumbnails run: | 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 + done + + - name: Convert PNG thumbnails to WebP + run: | + for png in $(find . -name "*.png"); do + cwebp $png -o ${png%.png}.webp done + - name: Clean up directory (Only keep STL and WebP files) + run: | + find . -type f ! -name "*.stl" ! -name "*.webp" -delete + - name: Deploy to GitHub Pages run: | git config user.name "GitHub Actions Bot" git config user.email "@users.noreply.github.com" git checkout -b gh-pages - git add ./*.stl **/*.stl - git commit -m "Update STL files generated by GitHub Actions" + git add ./*.stl **/*.stl ./*.webp **/*.webp + git commit -m "Update STL files and WebP thumbnails generated by GitHub Actions" git push -f origin gh-pages diff --git a/chocv1_08u/test1.scad b/chocv1_08u/test1.scad index 8b3416a..b610ae9 100644 --- a/chocv1_08u/test1.scad +++ b/chocv1_08u/test1.scad @@ -1,4 +1,5 @@ // https://qiita.com/zk_phi/items/ab99315ebaef66e84aa0 +// https://bebebe.hatenablog.jp/entry/2019/06/04/232501 $fs = 0.1;