refactor(ci): use temporary branch for cache builds
Some checks failed
CI / build (push) Has been cancelled

- Create unique temp branch (temp-cache-build-<run-id>) for each build
- Prevents any artifacts on main branch
- Auto-cleanup after successful push to similarity-cache-data
- Maintains clean git history
This commit is contained in:
matt 2026-02-20 12:47:27 -08:00
parent 048102c171
commit 97da117ccb

View file

@ -73,6 +73,15 @@ jobs:
fi fi
fi fi
- name: Create temporary build branch
if: steps.check_cache.outputs.needs_build == 'true'
run: |
# Create a unique temporary branch for this build
TEMP_BRANCH="temp-cache-build-${{ github.run_id }}"
echo "TEMP_BRANCH=$TEMP_BRANCH" >> $GITHUB_ENV
git checkout -b $TEMP_BRANCH
echo "Created temporary branch: $TEMP_BRANCH"
- name: Run initial setup - name: Run initial setup
if: steps.check_cache.outputs.needs_build == 'true' if: steps.check_cache.outputs.needs_build == 'true'
run: | run: |
@ -276,6 +285,14 @@ jobs:
echo "Successfully pushed cache to similarity-cache-data branch" echo "Successfully pushed cache to similarity-cache-data branch"
- name: Cleanup temporary branch
if: always() && steps.check_cache.outputs.needs_build == 'true'
run: |
# Return to original branch and delete temporary branch
git checkout ${{ github.ref_name }} 2>/dev/null || git checkout main
git branch -D $TEMP_BRANCH 2>/dev/null || true
echo "Cleaned up temporary branch: $TEMP_BRANCH"
- name: Summary - name: Summary
if: always() if: always()
run: | run: |