mirror of
https://github.com/shadoll/just-commons.git
synced 2025-12-20 04:27:43 +00:00
BREAKING CHANGES: - Complete restructure to Just module architecture (requires Just 1.31.0+) - Command syntax changed: 'just postgres-sql' → 'just postgres sql' - Import syntax changed: import → mod declarations NEW FEATURES: ✨ Module-based architecture with optional modules ✨ Built-in Just colors ({{RED}}, {{GREEN}}, etc.) replace custom variables ✨ Enhanced [confirm] attributes for all destructive operations ✨ Organized [group('name')] attributes for better UX ✨ Modern justfile with comprehensive help system ✨ Updated documentation with migration guide MODULES: 📦 postgres/ - PostgreSQL operations (sql, check, create-database, etc.) 📦 mysql/ - MySQL operations (sql, check, create-user, etc.) 📦 volumes/ - Volume management (clean-all, remove, list) 📦 container/ - Container operations (start, stop, logs, shell, exec) 📦 registry/ - Registry auth (login, logout, check) 📦 images/ - Image operations (build, push, pull, tag, clean) USAGE: just postgres sql "SELECT version();" just volumes clean-all just images build myapp This is Just Commons v2.0 - a complete modernization using all of Just's latest features.
65 lines
2.3 KiB
Plaintext
65 lines
2.3 KiB
Plaintext
# Container registry authentication and management
|
|
|
|
# Login to container registry
|
|
[group('registry')]
|
|
login:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [ -z "${GITHUB_USERNAME:-}" ] || [ -z "${GITHUB_TOKEN:-}" ]; then
|
|
echo "{{BOLD}}{{RED}}Error:{{NORMAL}} GITHUB_USERNAME and GITHUB_TOKEN environment variables must be set" >&2
|
|
echo "{{YELLOW}}Please set these in your .env file or environment{{NORMAL}}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
runtime=$(just _detect_runtime)
|
|
registry="${REGISTRY:-ghcr.io}"
|
|
|
|
echo -e "{{BLUE}}Logging into registry: $registry{{NORMAL}}"
|
|
echo "$GITHUB_TOKEN" | $runtime login "$registry" -u "$GITHUB_USERNAME" --password-stdin
|
|
|
|
echo -e "{{GREEN}}✓ Successfully logged into $registry{{NORMAL}}"
|
|
|
|
# Logout from container registry
|
|
[group('registry')]
|
|
logout:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
runtime=$(just _detect_runtime)
|
|
registry="${REGISTRY:-ghcr.io}"
|
|
|
|
echo -e "{{BLUE}}Logging out from registry: $registry{{NORMAL}}"
|
|
$runtime logout "$registry"
|
|
|
|
echo -e "{{GREEN}}✓ Successfully logged out from $registry{{NORMAL}}"
|
|
|
|
# Check registry authentication status
|
|
[group('registry')]
|
|
check:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
runtime=$(just _detect_runtime)
|
|
registry="${REGISTRY:-ghcr.io}"
|
|
|
|
echo -e "{{BLUE}}Registry Configuration:{{NORMAL}}"
|
|
echo -e "{{YELLOW}}Registry:{{NORMAL}} $registry"
|
|
echo -e "{{YELLOW}}Username:{{NORMAL}} ${GITHUB_USERNAME:-'Not set'}"
|
|
echo -e "{{YELLOW}}Token:{{NORMAL}} ${GITHUB_TOKEN:+'Set'}${GITHUB_TOKEN:-'Not set'}"
|
|
echo ""
|
|
|
|
echo -e "{{BLUE}}Testing registry authentication...{{NORMAL}}"
|
|
|
|
# Check if we can access the registry
|
|
if echo "$GITHUB_TOKEN" | $runtime login "$registry" -u "$GITHUB_USERNAME" --password-stdin >/dev/null 2>&1; then
|
|
echo -e "{{GREEN}}✓ Registry authentication successful{{NORMAL}}"
|
|
|
|
# Show configured registries
|
|
echo -e "{{BLUE}}Configured registries:{{NORMAL}}"
|
|
$runtime system info --format "{{{{.RegistryConfig.IndexConfigs}}}}" 2>/dev/null || echo "Registry config not available"
|
|
else
|
|
echo -e "{{RED}}✗ Registry authentication failed{{NORMAL}}"
|
|
echo -e "{{YELLOW}}Please check your GITHUB_USERNAME and GITHUB_TOKEN{{NORMAL}}"
|
|
exit 1
|
|
fi |