move pruning to github action

This commit is contained in:
kjeld Schouten-Lebbing 2021-08-31 11:10:53 +02:00
parent 6dedb20252
commit 28e815f7a9
No known key found for this signature in database
GPG Key ID: 4CDAD4A532BC1EDB
2 changed files with 56 additions and 23 deletions

56
.github/workflows/prune.yaml vendored Normal file
View File

@ -0,0 +1,56 @@
name: "Housekeeping"
on:
workflow_dispatch:
push:
branches:
- main
paths:
- ".github/workflows/housekeeping.yaml"
schedule:
- cron: "0 5 * * *"
jobs:
housekeeping:
runs-on: ubuntu-latest
name: "Housekeeping"
steps:
- name: Checkout branch
uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.BOT_TOKEN }}
- name: Containers - Fetch new application versions
run: |
for train in stable incubator
do
for chart in ${train}/*; do
if [ -f "${chart}/item.yaml" ]; then
maxchartversion=$(ls ${chart} | grep -v item.yaml | sort -Vr | head -n1)
maxchartversion=${maxchartversion%/}
chartname=$(basename ${chart})
for version in ${chart}/*; do
versionname=$(basename ${version})
if [ -f "${version}/Chart.yaml" ]; then
if [[ "${versionname}" != "${maxchartversion}" ]]; then
echo "Removing older version ${versionname} for ${chartname}"
rm -Rf ${version}
else
echo "${versionname} is the latest version, skipping..."
fi
fi
done
else
echo "Invalid App"
fi
done
done
- name: Commit and Push Housekeeping
run: |
git config user.name "TrueCharts-Bot"
git config user.email "bot@truecharts.org"
git add --all
git commit -sm "Daily Prune" || exit 0
git push

View File

@ -1,23 +0,0 @@
for train in stable incubator develop non-free deprecated
do
for chart in ${train}/*; do
if [ -f "${chart}/item.yaml" ]; then
maxchartversion=$(ls ${chart} | grep -v item.yaml | sort -Vr | head -n1)
maxchartversion=${maxchartversion%/}
chartname=$(basename ${chart})
for version in ${chart}/*; do
versionname=$(basename ${version})
if [ -f "${version}/Chart.yaml" ]; then
if [[ "${versionname}" != "${maxchartversion}" ]]; then
echo "Removing older version ${versionname} for ${chartname}"
rm -Rf ${version}
else
echo "${versionname} is the latest version, skipping..."
fi
fi
done
else
echo "Invalid App"
fi
done
done