Enable auto-deploy for LittleShop on main branch

- Added auto-deploy on successful builds for main branch
- Deployment uses commit SHA when no tag is present
- Manual deployment still available for tagged releases
- Follows same pattern as TeleBot deployment

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
SysAdmin 2025-09-27 09:54:48 +01:00
parent fd02836450
commit 191a9f27f2

View File

@ -34,25 +34,27 @@ deploy:vps:
- chmod 700 ~/.ssh - chmod 700 ~/.ssh
- ssh-keyscan -p "$VPS_PORT" "$VPS_HOST" >> ~/.ssh/known_hosts - ssh-keyscan -p "$VPS_PORT" "$VPS_HOST" >> ~/.ssh/known_hosts
script: script:
- echo "Deploying version $CI_COMMIT_TAG to VPS" - export VERSION="${CI_COMMIT_TAG:-$CI_COMMIT_SHORT_SHA}"
- echo "Deploying version $VERSION to VPS"
- echo "Building image from source..." - echo "Building image from source..."
- docker build -t littleshop:$CI_COMMIT_TAG . - docker build -t littleshop:$VERSION .
- echo "Copying image to VPS via SSH..." - echo "Copying image to VPS via SSH..."
- docker save littleshop:$CI_COMMIT_TAG | ssh -i /tmp/deploy_key -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" "docker load" - docker save littleshop:$VERSION | ssh -i /tmp/deploy_key -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" "docker load"
- echo "Deploying on VPS..." - echo "Deploying on VPS..."
- | - |
ssh -i /tmp/deploy_key -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" bash -s << EOF ssh -i /tmp/deploy_key -p "$VPS_PORT" "$VPS_USER@$VPS_HOST" bash -s << EOF
set -e set -e
export VERSION="$VERSION"
# Tag the image # Tag the image
docker tag littleshop:$CI_COMMIT_TAG localhost:5000/littleshop:$CI_COMMIT_TAG docker tag littleshop:\$VERSION localhost:5000/littleshop:\$VERSION
docker tag littleshop:$CI_COMMIT_TAG localhost:5000/littleshop:latest docker tag littleshop:\$VERSION localhost:5000/littleshop:latest
# Push to local registry # Push to local registry
echo "Pushing to local Docker registry..." echo "Pushing to local Docker registry..."
docker push localhost:5000/littleshop:$CI_COMMIT_TAG docker push localhost:5000/littleshop:\$VERSION
docker push localhost:5000/littleshop:latest docker push localhost:5000/littleshop:latest
# Navigate to deployment directory # Navigate to deployment directory
@ -89,6 +91,8 @@ deploy:vps:
name: production name: production
url: http://hq.lan url: http://hq.lan
rules: rules:
- if: '$CI_COMMIT_BRANCH == "main"'
when: on_success
- if: '$CI_COMMIT_TAG' - if: '$CI_COMMIT_TAG'
when: manual when: manual
tags: tags: