Skip to content

changed deploy-test.yml to include testing in containers and then del… #30

changed deploy-test.yml to include testing in containers and then del…

changed deploy-test.yml to include testing in containers and then del… #30

Workflow file for this run

name: Continuous Development Deploy to TDT4242 server
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"
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
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Dotenv Action
uses: falti/dotenv-action@v1.1.4
with:
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: 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!"
echo "Commit hash: ${{ github.sha }}"
echo "Branch: ${{ github.ref }}"
- name: Verify that gateway is available
run: docker ps