This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate STL and WebP Thumbnails using OpenSCAD | |
on: | |
push: | |
paths: | |
- "**/*.scad" | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Install OpenSCAD and WebP tools | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y openscad webp | |
- 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 "<email>@users.noreply.github.com" | |
git checkout -b gh-pages | |
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 |