From fecd0458b5cffd9109b882eddf0175765712b132 Mon Sep 17 00:00:00 2001 From: Matt Raible Date: Tue, 10 Feb 2026 12:52:11 -0700 Subject: [PATCH] Skip unnecessary rebuilds when no dependencies changed Add a check step to the rebuild workflow that compares the last commit touching dependency files against the last dist build commit. If no dependency files changed since the last rebuild, all subsequent steps are skipped, avoiding unnecessary install and build cycles. --- .github/workflows/rebuild.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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 }}