|
| 1 | +#!/bin/bash |
| 2 | +# DOCKER_USERNAME=<your-username> DOCKER_PASSWORD=<your-password> source ./tools/promote-stable.sh |
| 3 | + |
| 4 | +IMAGE_NAME="elementsproject/lightningd" |
| 5 | +MINIMUM_DAYS_BEFORE_STABLE=15 |
| 6 | + |
| 7 | +if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ]; then |
| 8 | + echo "❌ Oops! Looks like someone forgot their Docker Hub credentials at home!" |
| 9 | + echo "🔑 Please set DOCKER_USERNAME and DOCKER_PASSWORD as environment variables." |
| 10 | + echo "💡 Hint: We can't log in with 'your-username' and 'your-password' (nice try though!)" |
| 11 | + return 1 2>/dev/null || exit 1 |
| 12 | +fi |
| 13 | + |
| 14 | +# Get Docker image information |
| 15 | +DOCKER_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" \ |
| 16 | + https://hub.docker.com/v2/users/login/ | jq -r .token) |
| 17 | +LATEST_INFO=$(curl -s -H "Authorization: JWT $DOCKER_TOKEN" https://hub.docker.com/v2/repositories/${IMAGE_NAME}/tags/latest/) |
| 18 | +LAST_UPDATED=$(echo "$LATEST_INFO" | jq -r .last_updated) || 0 |
| 19 | +DAYS_OLD=$(( ($(date +%s) - $(date -d "$LAST_UPDATED" +%s)) / 86400 )) |
| 20 | + |
| 21 | +if [ $DAYS_OLD -ge $MINIMUM_DAYS_BEFORE_STABLE ]; then |
| 22 | + echo "🎂 Ah, the latest tag has aged beautifully for $DAYS_OLD days, like a perfectly fermented sourdough!" |
| 23 | + echo "📦 Time for its grand debut as 'stable'..." |
| 24 | + echo "" |
| 25 | + docker pull $IMAGE_NAME:latest |
| 26 | + docker tag $IMAGE_NAME:latest $IMAGE_NAME:stable |
| 27 | + docker push $IMAGE_NAME:stable |
| 28 | + echo "" |
| 29 | + echo "✅ 🎉 Congratulations! Your image has officially graduated to stable status!" |
| 30 | +else |
| 31 | + DAYS_REMAINING=$((MINIMUM_DAYS_BEFORE_STABLE - DAYS_OLD)) |
| 32 | + echo "⏰ Whoa there! This latest tag is only $DAYS_OLD days old." |
| 33 | + echo "🧀 It's like cheese - it needs time to mature! Wait for $DAYS_REMAINING more day(s)..." |
| 34 | + read -p "❓ But hey, it's your rodeo. Still want to promote it to stable? (y/n): " -n 1 -r |
| 35 | + echo "" |
| 36 | + |
| 37 | + if [[ $REPLY =~ ^[Yy]$ ]]; then |
| 38 | + echo "🤠 Living dangerously, I see! Alright, throwing caution to the wind..." |
| 39 | + echo "🚀 Strapping rockets to this latest image and sending it to stable anyway!" |
| 40 | + echo "" |
| 41 | + docker pull $IMAGE_NAME:latest |
| 42 | + docker tag $IMAGE_NAME:latest $IMAGE_NAME:stable |
| 43 | + docker push $IMAGE_NAME:stable |
| 44 | + echo "" |
| 45 | + echo "✅ 💥 Done! Let's hope this doesn't come back to haunt us..." |
| 46 | + else |
| 47 | + echo "🎯 Smart move! Your reputation as the cautious one remains intact." |
| 48 | + echo "☕ Grab a coffee, touch some grass, and revisit this in $DAYS_REMAINING day(s)." |
| 49 | + fi |
| 50 | +fi |
0 commit comments