Cleanup Unused Images #10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cleanup Unused Images | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 0' # Weekly on Sunday at midnight | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm install # Adjust if you have specific dependencies, but for this script native node is enough | |
| - name: Run cleanup script | |
| run: npm run cleanup:images | |
| - name: Stage changes | |
| run: git add -u | |
| - name: Commit and push changes | |
| run: | | |
| if ! git diff --cached --quiet; then | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| git commit -m "chore: cleanup unused images" | |
| git push | |
| else | |
| echo "No changes to commit" | |
| fi |