Skip to content

Commit

Permalink
Update deploy_test.yml
Browse files Browse the repository at this point in the history
trying another way
  • Loading branch information
Garima Ketan Chauhan authored and GitHub Enterprise committed Mar 24, 2025
1 parent 3ab1e01 commit 2d0586d
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions .github/workflows/deploy_test.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
name: Continuous Development Deploy to TDT4242 server
name: Production Deployment Workflow

on:
push:
branches:
- 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.yml" # Default to docker-compose.yml for production
type: choice
options:
- "docker-compose.dev.yml"
- "docker-compose.stag.yml"
- "docker-compose.yml"
- gargi-production # Trigger only for production branch

jobs:
deploy:
runs-on: self-hosted
env:
REPO_NAME: ${{ github.event.repository.name }}
COMPOSE_FILE: ${{ github.event.inputs.config || 'docker-compose.yml' }} # Default to docker-compose.yml for production
COMPOSE_FILE: docker-compose.yml

steps:
- name: Checkout repository
Expand All @@ -33,22 +22,18 @@ jobs:
export-variables: true
keys-case: bypass

- name: Check status of config file
run: |
env
docker compose version
cd $GITHUB_WORKSPACE
docker compose -f $COMPOSE_FILE --verbose config && printf "OK\n" || exit 1
- name: Set up test containers
run: docker-compose -f docker-compose.stag.yml up --build -d

- name: Run backend unit tests
run: docker exec secfit_stag_backend python manage.py test tests

- name: Tear down test containers
run: docker-compose -f docker-compose.stag.yml down

- 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!"
Expand Down

0 comments on commit 2d0586d

Please sign in to comment.