diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml index 840dafc..f5bd97c 100644 --- a/.github/workflows/rebuild.yml +++ b/.github/workflows/rebuild.yml @@ -21,17 +21,39 @@ jobs: uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 with: node-version: 22 + - name: Check if rebuild needed + id: check + run: | + LAST_BUILD=$(git log -1 --format=%H -- ui/extensions/hello/src/dist/) + if [ -z "$LAST_BUILD" ]; then + echo "skip=false" >> "$GITHUB_OUTPUT" + echo "No previous build found, rebuilding" + exit 0 + fi + CHANGES=$(git diff --name-only "$LAST_BUILD" HEAD -- ui/extensions/hello/package.json ui/extensions/hello/package-lock.json) + if [ -z "$CHANGES" ]; then + echo "skip=true" >> "$GITHUB_OUTPUT" + echo "No dependency changes since last build, skipping" + else + echo "skip=false" >> "$GITHUB_OUTPUT" + echo "Dependency changes detected:" + echo "$CHANGES" + fi - name: Install dependencies + if: steps.check.outputs.skip != 'true' run: npm ci working-directory: ui/extensions/hello - name: Build React app + if: steps.check.outputs.skip != 'true' run: npm run build working-directory: ui/extensions/hello - name: Create commit + if: steps.check.outputs.skip != 'true' run: | git add . git commit -a -m "Rebuild UI with latest dependencies" || true - name: Create Pull Request + if: steps.check.outputs.skip != 'true' uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11 with: token: ${{ secrets.GITHUB_TOKEN }}