Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/purge-tutorial-history.yml
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 39 in .github/workflows/purge-tutorial-history.yml

View workflow job for this annotation

GitHub Actions / checks / checks

secrets/gcp-api-key

Uncovered a GCP API key, which could lead to unauthorized access to Google Cloud services and data breaches.
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."
Loading