Files
quantum_backend/.gitea/workflows/deploy-remote.yml
deowl 94bd0cda31
Some checks failed
Build and Deploy Docker Image / build-and-push (push) Has been cancelled
Update .gitea/workflows/deploy-remote.yml
2026-05-24 20:12:33 +00:00

68 lines
2.0 KiB
YAML

name: Deploy to Remote Server
on:
workflow_run:
workflows: ["Build and Deploy Docker Image"]
types:
- completed
branches: ["main"]
workflow_dispatch:
inputs:
image_tag:
description: "Image tag to deploy (default: latest)"
required: false
default: "latest"
env:
GITEA_INSTANCE_URL: git.deowl.ru
IMAGE_NAME: vkrb/quantum_backend
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
REMOTE_PORT: ${{ secrets.REMOTE_PORT }}
COMPOSE_PATH: /usr/local/share/vkrb/quantum_backend
jobs:
deploy:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.REMOTE_HOST }}
port: ${{ secrets.REMOTE_PORT }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: true
script: |
cd ${{ env.COMPOSE_PATH }}
# Get the tag to deploy
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.image_tag }}"
else
TAG="${{ github.event.workflow_run.head_sha }}"
fi
# Use 'latest' if no specific tag
if [ -z "$TAG" ]; then
TAG="latest"
fi
echo "Deploying tag: $TAG"
# Update .env file with the tag (if you're using env_file)
echo "IMAGE_TAG=$TAG" > .env.tag
# Pull only the quantum-backend service (not 'app'!)
docker compose pull quantum-backend
# Redeploy with the new image - use correct service name
docker compose up -d --no-deps --force-recreate quantum-backend
# Clean up old images
docker image prune -f
# Check container status
docker compose ps