Skip to content

Commit

Permalink
update: cache update
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchayan721 committed Aug 29, 2023
1 parent 2be583a commit 227f3f0
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,35 @@ jobs:
echo "SSH Keys Setup Completed"
echo "SSHing into Staging Server"
ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} -p ${{ secrets.PORT }} -i ~/.ssh/id_rsa <<EOF
echo "Change Directory to ims-website"
ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} -p ${{ secrets.PORT }} -i ~/.ssh/id_rsa <<'EOF'
# Change to the project directory
cd ~/ims-website
echo "Pulling Latest Code from Development Branch"
git pull origin development
echo "Cleaning up old Docker images"
docker image prune -a -f
echo "Cleaning up old log files"
find ~/ims-website/logs/* -mtime +7 -exec rm {} \\;
# Calculate Docker cache size in bytes
CACHE_SIZE=$(docker images --filter "dangling=true" -q --no-trunc | xargs -r docker inspect --format='{{.Size}}' | awk '{s+=$1} END {print s}')
echo "Rebuilding Docker Containers"
# Convert 2GB to bytes (2 * 1024 * 1024 * 1024)
# LIMIT=2147483648
# Convert 40MB to bytes (40 * 1024 * 1024)
LIMIT= 41943040
# Check if cache size exceeds the limit and prune if necessary
if [ "$CACHE_SIZE" -gt "$LIMIT" ]; then
echo "Cache size exceeded 2GB. Cleaning..."
docker system prune -af
else
echo "Cache size is within limit."
fi
# Continue with your existing deployment steps
git pull origin development
docker compose build
echo "Starting Docker Containers"
docker compose up -d
exit
EOF
echo "Deployment and Cleanup on Staging Server Completed"
- name: Gathering Email and Mail List
Expand Down

0 comments on commit 227f3f0

Please sign in to comment.