From 7ac6915aab5f7be3d1ce07912234647d6742cff4 Mon Sep 17 00:00:00 2001 From: andres Date: Sat, 13 Apr 2024 13:08:14 +0200 Subject: [PATCH] update script --- .github/workflows/deploy.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index db1b248..acfa032 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,7 +32,18 @@ jobs: username: root password: ${{ secrets.SSH_PASSWORD }} # Using password instead of key script: | + echo "Pulling latest Docker image..." docker pull ershisan99/flashcards:latest - docker stop flashcards || true - docker rm flashcards || true + + echo "Checking if the container 'flashcards' exists..." + if [ $(docker ps -a -q -f name=^/flashcards$) ]; then + echo "Container exists. Stopping and removing..." + docker stop flashcards + docker rm flashcards + else + echo "No existing container to stop or remove." + fi + + echo "Starting new container..." docker run -d --name flashcards -p 80:3333 ershisan99/flashcards:latest +