Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
2.1 kB · 67 lines
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#!/usr/bin/env fish
# Script to programmatically set ports 8888 and 8889 to public in GitHub Codespaces# This runs on container startup to ensure the ports are always public
# Check if we're running in a Codespaceif test -z "$CODESPACE_NAME" echo "⚠️ Not running in a GitHub Codespace, skipping port visibility setup" exit 0end
echo "🔓 Setting ports 8888 and 8889 to public visibility..."
# Function to set a port to publicfunction set_single_port_public set -l port $argv[1] set -l max_attempts 60 set -l attempt 0 while test $attempt -lt $max_attempts # Try using gh CLI without GH_TOKEN (it uses its own auth) if env -u GH_TOKEN gh codespace ports visibility $port:public -c $CODESPACE_NAME 2>/dev/null echo "✅ Port $port set to public" return 0 end set attempt (math $attempt + 1) # Log progress every 10 seconds if test (math $attempt % 10) -eq 0 echo "⏳ Waiting for port $port to be forwarded... ($attempt/$max_attempts seconds)" end sleep 1 end echo "⚠️ Could not set port $port to public after 60 seconds" return 1end
# Function to set both ports to publicfunction set_ports_public set -l success_count 0 # Set port 8888 (main site) if set_single_port_public 8888 set success_count (math $success_count + 1) end # Set port 8889 (session server) if set_single_port_public 8889 set success_count (math $success_count + 1) end if test $success_count -eq 2 echo "✅ All ports configured successfully" return 0 else echo "⚠️ Some ports could not be configured" echo "📝 Please manually set ports to public in the Ports panel" echo "📝 Or run: env -u GH_TOKEN gh codespace ports visibility PORT:public -c $CODESPACE_NAME" return 1 endend
# Run the function in the background so it doesn't block container startupset_ports_public &