mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-01-11 22:40:31 +00:00
ci(pages_cleanup): remove dirs that don't have existing related branch
This commit is contained in:
parent
ad5ab5c634
commit
9e33186708
1 changed files with 23 additions and 6 deletions
29
.github/workflows/pages_cleanup.yml
vendored
29
.github/workflows/pages_cleanup.yml
vendored
|
|
@ -18,13 +18,30 @@ jobs:
|
|||
ref: gh-pages
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Delete directories older than 1 year
|
||||
- name: Delete directories that don't have existing branch
|
||||
run: |
|
||||
for dir in $(find . -mindepth 1 -maxdepth 2 -type d -not -path '*/\.*'); do
|
||||
if ! git log -1 --since="1 year ago" -- "$dir" | grep -q .; then
|
||||
echo "Deleting $dir"
|
||||
rm -rf "$dir"
|
||||
fi
|
||||
branches=( $(git branch -r | grep origin | grep -v HEAD | sed 's|origin/||') )
|
||||
declare -p branches
|
||||
|
||||
find . -mindepth 1 -maxdepth 2 -type d -not -path '*/\.*' | while read -r dir; do
|
||||
path="${dir#./}"
|
||||
|
||||
if [[ " ${branches[*]} " =~ " $path " ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
keep_parent=false
|
||||
for branch in "${branches[@]}"; do
|
||||
if [[ "$branch" == "$path/"* ]]; then
|
||||
keep_parent=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if ! $keep_parent; then
|
||||
echo "Deleting $dir"
|
||||
rm -rf "$dir"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Commit and push
|
||||
|
|
|
|||
Loading…
Reference in a new issue