🧼 Clean S3 #35
This file contains 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: 🧼 Clean S3 | |
on: | |
schedule: | |
- cron: "5 1 */7 * *" | |
workflow_dispatch: | |
jobs: | |
clean_s3: | |
runs-on: ubuntu-22.04 | |
steps: | |
- run: | | |
sudo apt install -y s3cmd | |
echo "${{ secrets.S3CMD_CFG }}" > ~/.s3cfg | |
# Delete files older than 120 days | |
s3cmd ls -r s3://qfieldapks/ | awk -v dys="120" 'BEGIN { depoch=(dys*86400);cepoch=(systime()-depoch) } { gsub("-"," ",$1);gsub(":"," ",$2 );if (mktime($1" "$2" 00")<=cepoch) { print "s3cmd del "$4 } }' | bash | |
s3cmd du s3://qfieldapks/ |