Fix GHCR authentication: add fallback to local build + improved error handling
This commit is contained in:
24
.github/workflows/ci-cd.yml
vendored
24
.github/workflows/ci-cd.yml
vendored
@@ -219,11 +219,27 @@ jobs:
|
||||
# Copy production docker compose file to the active compose.yml
|
||||
cp deploy-production/docker-compose.prod.yml compose.yml
|
||||
|
||||
# Login to GitHub Container Registry
|
||||
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
|
||||
# Try to login to GitHub Container Registry and pull images
|
||||
echo "Attempting to pull images from GitHub Container Registry..."
|
||||
if echo $DEPLOY_TOKEN | docker login ghcr.io -u remmerinio --password-stdin; then
|
||||
echo "✅ Successfully logged into GHCR"
|
||||
if docker-compose -f compose.yml pull; then
|
||||
echo "✅ Successfully pulled images from GHCR"
|
||||
USE_REMOTE_IMAGES=true
|
||||
else
|
||||
echo "⚠️ Failed to pull images from GHCR, will build locally"
|
||||
USE_REMOTE_IMAGES=false
|
||||
fi
|
||||
else
|
||||
echo "⚠️ Failed to login to GHCR, will build locally"
|
||||
USE_REMOTE_IMAGES=false
|
||||
fi
|
||||
|
||||
# Pull latest images
|
||||
docker-compose -f compose.yml pull
|
||||
# If we couldn't pull from GHCR, build locally
|
||||
if [ "$USE_REMOTE_IMAGES" = "false" ]; then
|
||||
echo "🔨 Building images locally from source code..."
|
||||
docker build -t ghcr.io/remmerinio/stiftung-management-system:latest ./app
|
||||
fi
|
||||
|
||||
# Stop containers
|
||||
docker-compose -f compose.yml down
|
||||
|
||||
Reference in New Issue
Block a user