diff --git a/.github/workflows/build-and-preview-site.yml b/.github/workflows/build-and-preview-site.yml index 37850c7..7cf0708 100644 --- a/.github/workflows/build-and-preview-site.yml +++ b/.github/workflows/build-and-preview-site.yml @@ -26,7 +26,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: public-dir - path: ./public-dir.zip + path: public-dir.zip retention-days: 1 - name: Trigger Inner workflow run: echo "triggering inner workflow" \ No newline at end of file diff --git a/.github/workflows/preview-site.yml b/.github/workflows/preview-site.yml index 73446ca..269826c 100644 --- a/.github/workflows/preview-site.yml +++ b/.github/workflows/preview-site.yml @@ -8,7 +8,9 @@ on: jobs: deploy-preview: - if: github.repository == 'meshery-extensions/shape-builder' + if: > + github.repository == 'meshery-extensions/shape-builder' && + github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-24.04 steps: - name: Checkout code @@ -24,8 +26,9 @@ jobs: - name: Unzip Site run: | - rm -rf ./docs/_site - unzip public-dir.zip + rm -rf docs/_site + mkdir -p docs/_site + unzip public-dir.zip -d docs/_site rm -f public-dir.zip - name: Deploy to Netlify diff --git a/script.sh b/script.sh index 22200a8..b509bac 100644 --- a/script.sh +++ b/script.sh @@ -1,7 +1,21 @@ -#! /usr/bin/env bash +#!/usr/bin/env bash +set -e -if [ -f public-dir.zip ]; then - rm -rf public-dir.zip +ZIP_NAME="public-dir.zip" +BUILD_DIR="site/public" + +# Ensure build output exists and is not empty +if [ ! -d "$BUILD_DIR" ] || [ -z "$(ls -A "$BUILD_DIR")" ]; then + echo "Build output missing or empty at $BUILD_DIR" + exit 1 fi -mkdir -p public -zip -r public-dir.zip . -i ./public \ No newline at end of file + +rm -f "$ZIP_NAME" + +# Zip ONLY the contents of the built site +( + cd "$BUILD_DIR" + zip -r "../../$ZIP_NAME" . +) + +echo "Zipped site contents into $ZIP_NAME" diff --git a/site/src/components/ShapeBuilder/index.js b/site/src/components/ShapeBuilder/index.js index 6a6132f..5ab1d15 100644 --- a/site/src/components/ShapeBuilder/index.js +++ b/site/src/components/ShapeBuilder/index.js @@ -67,7 +67,7 @@ const ShapeBuilder = () => { const points = getPlottedPoints(poly); if (!points || points.length === 0) return; - + if (!basePointsRef.current) { basePointsRef.current = points; } @@ -92,10 +92,10 @@ const ShapeBuilder = () => { const handleScaleChange = (newScale) => { const clampedScale = Math.max(MIN_SCALE, Math.min(MAX_SCALE, newScale)); setScale(clampedScale); - + const matchingPreset = SCALE_PRESETS.find(p => Math.abs(p - clampedScale) < 0.01); setCurrentPreset(matchingPreset || clampedScale); - + applyScale(clampedScale); }; @@ -250,7 +250,7 @@ const ShapeBuilder = () => { - +