diff --git a/.github/workflows/purge-tutorial-history.yml b/.github/workflows/purge-tutorial-history.yml new file mode 100644 index 000000000..76cf9767d --- /dev/null +++ b/.github/workflows/purge-tutorial-history.yml @@ -0,0 +1,51 @@ +name: Purge Tutorial History (one-shot) +on: + workflow_dispatch: + +jobs: + purge: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Install git-filter-repo + run: pip install git-filter-repo + + - name: Full mirror clone + run: | + git clone --mirror https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/sap-tutorials/Tutorials.git repo.git + + - name: Verify target exists in history + run: | + cd repo.git + COUNT=$(git log --all --oneline -- "tutorials/cp-sdk-android-wizard-teched18-01/google-services.json" | wc -l) + echo "Commits with target file: $COUNT" + if [ "$COUNT" -eq 0 ]; then echo "Nothing to purge"; exit 0; fi + + - name: Purge tutorial directory from all history + run: | + cd repo.git + git filter-repo --invert-paths \ + --path "tutorials/cp-sdk-android-wizard-teched18-01/" \ + --force + + - name: Verify purge succeeded + run: | + cd repo.git + COUNT=$(git log --all --oneline -- "tutorials/cp-sdk-android-wizard-teched18-01/google-services.json" 2>/dev/null | wc -l) + echo "Commits with target after purge: $COUNT" + if [ "$COUNT" -ne 0 ]; then echo "PURGE FAILED"; exit 1; fi + # Also grep for the key string in packed objects + if git grep "AIzaSyAQu5bKzWBZcGO6Hj5Y0NH03g1N0hOqt2Q" $(git rev-list --all) 2>/dev/null | grep -q .; then + echo "KEY STILL PRESENT IN HISTORY"; exit 1 + fi + echo "Purge verified clean." + + - name: Re-add origin and force-push all heads and tags + run: | + cd repo.git + git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/sap-tutorials/Tutorials.git + # Push all rewritten heads (NOT refs/pull/*) + git push origin --force 'refs/heads/*:refs/heads/*' + git push origin --force 'refs/tags/*:refs/tags/*' + echo "Force-push complete."