From 23095e21e5f79358486e1b514ea1b9d71e8d8c69 Mon Sep 17 00:00:00 2001 From: EliasKnudsen Date: Wed, 10 Apr 2024 17:27:09 +0200 Subject: [PATCH] Delete containers and images related to tags --- .github/workflows/autoredeploy.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/autoredeploy.yml b/.github/workflows/autoredeploy.yml index b709dc9..6a3466a 100644 --- a/.github/workflows/autoredeploy.yml +++ b/.github/workflows/autoredeploy.yml @@ -11,14 +11,17 @@ jobs: runs-on: self-hosted steps: - uses: actions/checkout@v3 - - name: Stop and remove containers by tag + - name: Stop and remove containers, then remove images run: | - # Stop containers running from 'backend:outreach' image - docker ps -q --filter ancestor=backend:outreach | xargs -r docker stop - # Stop containers running from 'frontend:outreach' image - docker ps -q --filter ancestor=frontend:outreach | xargs -r docker stop + # Find and stop containers running from 'backend:outreach' image, then remove them + docker ps -aq --filter ancestor=backend:outreach | xargs -r docker stop | xargs -r docker rm + + # Find and stop containers running from 'frontend:outreach' image, then remove them + docker ps -aq --filter ancestor=frontend:outreach | xargs -r docker stop | xargs -r docker rm + # Now, remove the images docker rmi backend:outreach frontend:outreach || true + - name: Create .env files run: | # Create .env with all variables except HOST_URL Backend