add function wait_assert_file_exist when generating stl with sp2 api #211
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: Preview | |
on: [push] | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
# https://github.com/actions/setup-python/issues/853 | |
python-version: ["3.10"] | |
os: [ubuntu-24.04] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# python packages included in install_dependencies | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: install dependencies | |
run: | | |
chmod +x ./install_dependencies.sh | |
sudo ./install_dependencies.sh | |
- name: Install jq | |
run: sudo apt-get update && sudo apt-get install -y jq | |
#- name: pip configuration report | |
# run: | | |
# mkdir test | |
# pip list > ./test/pip_list.txt | |
#- name: test pylele.sh | |
# run: | | |
# source pylele.sh | |
- name: test pylele2.sh | |
run: | | |
source ./src/pylele2.sh -odoff -str -tnr | |
- name: Copy STL file to GitHub Pages | |
run: | | |
mkdir -p docs | |
cp build/LeleAllAssembly/LeleAllAssembly.stl docs/ | |
- name: Upload to Sketchfab | |
env: | |
SKETCHFAB_API_TOKEN: ${{ secrets.SKETCHFAB_API_TOKEN }} | |
run: | | |
# Format the current date and time | |
model_name="pylele2_$(date +'%Y-%m-%d-%Hh%Mm%Ss')" | |
response=$(curl -X POST -H "Authorization: Token ${SKETCHFAB_API_TOKEN}" \ | |
-F "modelFile=@build/LeleAllAssembly/LeleAllAssembly.stl" \ | |
-F "name=${model_name}" \ | |
-F "description=Uploaded via GitHub Actions on $(date +'%Y-%m-%d at %H:%M:%S')" \ | |
-F "tags=model,stl,python,ukulele,music" \ | |
https://api.sketchfab.com/v3/models) | |
# -F "color=red" \ # Set a color for the model | |
# -F "texture=@path/to/your/texture.jpg" \ # Path to your texture file | |
# -F "settings[autorotate]=true" \ # Enable autorotation | |
# -F "settings[defaultView]=0" \ # Set default view angle (0 = front view) | |
# -F "settings[showAnnotations]=true" \ # Show annotations if any | |
# -F "settings[showEnvironment]=true" \ # Show environment lighting | |
echo "Sketchfab query response: $response" | |
# Extract uri and uid using jq | |
model_uri=$(echo "$response" | jq -r '.uri') | |
model_uid=$(echo "$response" | jq -r '.uid') | |
# Output the extracted values | |
echo "Model URI: $model_uri" | |
echo "Model UID: $model_uid" | |
# Check if model_id is empty, indicating failure | |
if [ -z "$model_uid" ]; then | |
echo "Error: Failed to upload STL to Sketchfab." | |
exit 1 | |
fi | |
echo "Model uploaded successfully. Model ID: $model_uid" | |
echo "Model URL: https://sketchfab.com/3d-models/$model_name-$model_uid" | |
echo "::set-output name=model_url::https://sketchfab.com/3d-models/$model_name-$model_uid" | |
# - name: Update GitHub Pages HTML | |
# run: | | |
# model_url=${{ steps.upload_sketchfab.outputs.model_url }} | |
# echo "<!DOCTYPE html> | |
# <html lang='en'> | |
# <head> | |
# <meta charset='UTF-8'> | |
# <meta name='viewport' content='width=device-width, initial-scale=1.0'> | |
# <title>STL Model Preview</title> | |
# </head> | |
# <body> | |
# <h1>STL Model Uploaded</h1> | |
# <p>View your model on Sketchfab: <a href='$model_url'>$model_url</a></p> | |
# </body> | |
# </html>" > docs/index.html | |
# - name: Commit and Push Changes | |
# run: | | |
# git config --local user.email "[email protected]" | |
# git config --local user.name "Your Name" | |
# git add docs/index.html | |
# git commit -m "Update Sketchfab model link" | |
# git push | |
#- name: upload demo stl | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# # path depends on the tag and the module name | |
# name: pylele_stl_out_${{ matrix.python-version }}_${{ matrix.os }} | |
# path: build/LeleAllAssembly/LeleAllAssembly.stl | |
# # compression-level: 0 # no compression | |
# | |
# - name: convert to glb | |
# run: | | |
# python3 ./conversion/stl2glb.py build/LeleAllAssembly/LeleAllAssembly.stl | |
#- name: upload glb | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# # path depends on the tag and the module name | |
# name: pylele_glb_out_${{ matrix.python-version }}_${{ matrix.os }} | |
# path: build/LeleAllAssembly/LeleAllAssembly.glb | |
# # compression-level: 0 # no compression |