-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (29 loc) · 1.04 KB
/
cleanHistory.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Clean output/*.png History
on:
workflow_dispatch: # Manual trigger for safety
permissions:
contents: write # Required for force pushing
jobs:
filter-repo:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Get full history
- name: Install git-filter-repo
run: |
sudo apt-get update && sudo apt-get install -y python3-pip
pip3 install git-filter-repo
- name: Clean output/*.png history
run: |
# Remove all historical PNG files in the output/ directory
git filter-repo --path-glob 'output/*.png' --invert-paths
- name: Reconfigure Git remote
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
# Re-add the origin remote
git remote add origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
- name: Force push cleaned history
run: git push origin HEAD:main --force