Skip to content

Commit

Permalink
Merge branch 'master' into icons-update-feb
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto authored Feb 12, 2025
2 parents 5ddc6ce + 4fe2a25 commit 3b5fdd3
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/clean-up-previews.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Clean up preview site

on: workflow_dispatch
on:
schedule:
- cron: '00 8 * * 1'

jobs:
delete:
Expand All @@ -9,21 +11,32 @@ jobs:
env:
CI: true
PREVIEW_DIR: preview
DAYS_OLD: 7
DAYS_OLD: 12
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0

- name: Delete old preview directories
run: |
for i in `find ${{ env.PREVIEW_DIR }} -mindepth 1 -maxdepth 1 -type d -mtime +${{ env.DAYS_OLD }} -print`; do echo -e "Deleting directory $i";rm -rf $i; done
if [[ $(git status --porcelain --untracked-files=no | wc -l) -eq 0 ]]; then echo "No directories to clean up";exit 0; fi
DATE_FROM_DAYS_AGO=`date --date="${{env.DAYS_OLD}} days ago" +"%Y"-"%m"-"%d"`;
for i in $(find ${{ env.PREVIEW_DIR }} -mindepth 1 -maxdepth 1 -type d -print); do
if [[ $(git log --before=$DATE_FROM_DAYS_AGO $i | tail -1) ]]; then
echo "Deleting directory $i"
rm -rf $i
fi
done
if [[ $(git status --porcelain --untracked-files=no | wc -l) -eq 0 ]]; then
echo "No directories to clean up"
exit 0
fi
git config --local user.name 'GitHub Actions'
git config --local user.email '[email protected]'
git add ${{ env.PREVIEW_DIR }}
git commit --quiet -m "Clean up old preview directories"
git pull --rebase
git push
shell: bash
env:
Expand Down

0 comments on commit 3b5fdd3

Please sign in to comment.