From 3ab1e01ebcd093c3829c7ccde698b16d4c4a707f Mon Sep 17 00:00:00 2001 From: CodingGirlGargi Date: Mon, 24 Mar 2025 22:43:40 +0100 Subject: [PATCH] changed deploy-test.yml to include testing in containers and then deleting the containers --- .github/workflows/deploy_test.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml index bcf67f8..a4a00cc 100644 --- a/.github/workflows/deploy_test.yml +++ b/.github/workflows/deploy_test.yml @@ -3,13 +3,13 @@ name: Continuous Development Deploy to TDT4242 server on: push: branches: - - main # Or your development branch + - gargi-production # Trigger deployment on push to the production branch workflow_dispatch: inputs: config: description: "Which compose config file to deploy" required: true - default: "docker-compose.dev.yml" + default: "docker-compose.yml" # Default to docker-compose.yml for production type: choice options: - "docker-compose.dev.yml" @@ -21,7 +21,7 @@ jobs: runs-on: self-hosted env: REPO_NAME: ${{ github.event.repository.name }} - COMPOSE_FILE: ${{ github.event.inputs.config || 'docker-compose.dev.yml' }} # Use default if not provided + COMPOSE_FILE: ${{ github.event.inputs.config || 'docker-compose.yml' }} # Default to docker-compose.yml for production steps: - name: Checkout repository @@ -43,6 +43,12 @@ jobs: - name: Build and run docker image run: docker compose -f $COMPOSE_FILE up --force-recreate --build -d + - name: Run tests in staging (before production deployment) + run: | + docker compose -f docker-compose.stag.yml up --build -d + docker exec secfit_stag_backend python manage.py test tests + docker compose -f docker-compose.stag.yml down + - name: Print deployment message run: | echo "Code has been updated and deployed to the server!"