fun/.github/workflows/clear.yml
2025-12-18 20:24:05 +08:00

59 lines
1.3 KiB
YAML
Executable file

name: Clean up the garbage
on:
schedule:
- cron: '0 4 7 * *'
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout target repo
uses: actions/checkout@v6
with:
repository: cluntop/tvbox
token: ${{ secrets.GIT_TOKEN }}
fetch-depth: 1
- name: Install git-filter-repo
run: |
sudo apt-get update
sudo apt-get install -y python3-pip
pip3 install git-filter-repo
- name: Configure Git
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Compressing
run: |
git prune-packed
git reflog expire --expire=now --all
git gc --prune=now --aggressive
- name: Force Push Changes
run: |
git push origin --force --all
git push origin --force --tags
- name: Reset History
run: |
git checkout --orphan latest_branch
git add -A
git commit -m "purge history"
git branch -D main
git branch -m main
- name: Force Push to Remote
run: |
git push -f origin main