Update .gitea/workflows/deploy-remote.yml
Some checks failed
Build and Deploy Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
2026-05-24 20:00:07 +00:00
parent a118cf49a4
commit a22d2dd61d

View File

@@ -1,14 +1,11 @@
name: Deploy to Remote Server name: Deploy to Remote Server
on: on:
# Trigger after successful build (using workflow_run)
workflow_run: workflow_run:
workflows: ["Build and Deploy Docker Image"] workflows: ["Build and Deploy Docker Image"]
types: types:
- completed - completed
branches: ["main"] branches: ["main"]
# Allow manual trigger for redeployment
workflow_dispatch: workflow_dispatch:
inputs: inputs:
image_tag: image_tag:
@@ -21,12 +18,11 @@ env:
IMAGE_NAME: vkrb/quantum_backend IMAGE_NAME: vkrb/quantum_backend
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }} REMOTE_USER: ${{ secrets.REMOTE_USER }}
REMOTE_PORT: ${{ secrets.REMOTE_PORT }} # Add this REMOTE_PORT: ${{ secrets.REMOTE_PORT }}
COMPOSE_PATH: /usr/local/share/vkrb/quantum_backend COMPOSE_PATH: /usr/local/share/vkrb/quantum_backend
jobs: jobs:
deploy: deploy:
# Only run if the build workflow succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -35,7 +31,7 @@ jobs:
uses: appleboy/ssh-action@v1.0.3 uses: appleboy/ssh-action@v1.0.3
with: with:
host: ${{ secrets.REMOTE_HOST }} host: ${{ secrets.REMOTE_HOST }}
port: ${{ secrets.REMOTE_PORT }} # Add this line port: ${{ secrets.REMOTE_PORT }}
username: ${{ secrets.REMOTE_USER }} username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }} key: ${{ secrets.SSH_PRIVATE_KEY }}
script_stop: true script_stop: true
@@ -56,12 +52,14 @@ jobs:
echo "Deploying tag: $TAG" echo "Deploying tag: $TAG"
# Method 1: Using environment variable (recommended) # Update .env file with the tag (if you're using env_file)
export IMAGE_TAG=$TAG echo "IMAGE_TAG=$TAG" > .env
docker compose pull app # Pull only the app service
# Redeploy with the new image # Pull only the quantum-backend service (not 'app'!)
docker compose up -d --no-deps --force-recreate 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 # Clean up old images
docker image prune -f docker image prune -f